package com.infodms.dms.actions.claim.dealerClaimMng;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;

import com.infodms.dms.actions.common.FileUploadManager;
import com.infodms.dms.actions.repairOrder.WrRuleUtil;
import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.bean.ClaimListBean;
import com.infodms.dms.bean.NewPartBean;
import com.infodms.dms.bean.TtAsActivityBean;
import com.infodms.dms.bean.TtAsWrApplicationExtBean;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.DBLockUtil;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.common.Utility;
import com.infodms.dms.common.getCompanyId.GetOemcompanyId;
import com.infodms.dms.dao.claim.auditing.ClaimAuditingDao;
import com.infodms.dms.dao.claim.dealerClaimMng.ClaimBillMaintainDAO;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.FsFileuploadPO;
import com.infodms.dms.po.TmBusinessChngCodePO;
import com.infodms.dms.po.TmDealerPO;
import com.infodms.dms.po.TmPtPartBaseExtPO;
import com.infodms.dms.po.TmPtPartBasePO;
import com.infodms.dms.po.TmPtSupplierPO;
import com.infodms.dms.po.TmVehicleExtPO;
import com.infodms.dms.po.TmVehiclePO;
import com.infodms.dms.po.TtAsActivityPO;
import com.infodms.dms.po.TtAsRepairOrderExtPO;
import com.infodms.dms.po.TtAsRepairOrderPO;
import com.infodms.dms.po.TtAsRoAddItemPO;
import com.infodms.dms.po.TtAsRoLabourPO;
import com.infodms.dms.po.TtAsRoRepairPartPO;
import com.infodms.dms.po.TtAsWrApplicationExtPO;
import com.infodms.dms.po.TtAsWrApplicationPO;
import com.infodms.dms.po.TtAsWrGamefeePO;
import com.infodms.dms.po.TtAsWrInformationqualityExtPO;
import com.infodms.dms.po.TtAsWrInformationqualityPO;
import com.infodms.dms.po.TtAsWrLabouritemPO;
import com.infodms.dms.po.TtAsWrModelGroupPO;
import com.infodms.dms.po.TtAsWrModelItemPO;
import com.infodms.dms.po.TtAsWrNetitemExtPO;
import com.infodms.dms.po.TtAsWrNetitemPO;
import com.infodms.dms.po.TtAsWrOtherfeePO;
import com.infodms.dms.po.TtAsWrOutrepairPO;
import com.infodms.dms.po.TtAsWrPartsitemPO;
import com.infodms.dms.po.TtAsWrQamaintainPO;
import com.infodms.dms.po.TtAsWrWrlabinfoExtPO;
import com.infodms.dms.po.TtAsWrWrlabinfoPO;
import com.infodms.dms.po.TtDealerActualSalesPO;
import com.infodms.dms.po.VwMaterialGroupPO;
import com.infodms.dms.util.CommonUtils;
import com.infodms.dms.util.StringUtil;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.dms.chana.vo.WarrantyPartVO;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.po3.bean.PageResult;

/**
 * 
 * @ClassName: ClaimBillMaintainMain
 * @Description: TODO(索赔单维护)
 * @author wangchao
 * @date May 31, 2010 4:17:16 PM
 * 
 */
public class ClaimBillMaintainMain {
	private Logger logger = Logger.getLogger(ClaimBillMaintainMain.class);
	private final ClaimBillMaintainDAO dao = ClaimBillMaintainDAO.getInstance();
	private final ClaimAuditingDao daom = ClaimAuditingDao.getInstance();
	private final String CLAIM_BILL_URL = "/jsp/claim/dealerClaimMng/claimBillMaintain.jsp";// 主页面（查询）
	private final String CLAIM_BILL_ADD_URL = "/jsp/claim/dealerClaimMng/2claimBillMaintainAdd.jsp";// 增加页面
	private final String CLAIM_BILL_MODIFY_URL = "/jsp/claim/dealerClaimMng/2claimBillMaintainModify.jsp";// 修改页面
	private final String SHOW_VIN_URL = "/jsp/claim/dealerClaimMng/showVin.jsp";// VIN选择
	private final String MAIN_TIME_URL = "/jsp/claim/dealerClaimMng/showMainTime.jsp";// 工时选择
	private final String TIME_URL = "/jsp/claim/dealerClaimMng/showTime.jsp";// 工时选择
	private final String PARTCODE_URL = "/jsp/claim/dealerClaimMng/showPartCode.jsp";// 配件选择
	private final String MAIN_PARTCODE_URL = "/jsp/claim/dealerClaimMng/showMainPartCode.jsp";// 配件选择
	private final String DOWN_PARTCODE_URL = "/jsp/claim/dealerClaimMng/showDownPartCode.jsp";// 配件选择
	private final String RO_URL = "/jsp/claim/dealerClaimMng/showRo.jsp";
	private final String RO_DETAIL_URL = "/jsp/claim/dealerClaimMng/showRoAll.jsp";
	private final String RO_ITEM_LABOUR = "/jsp/claim/dealerClaimMng/showRoItemWorkHours.jsp";
	private final String RO_ITEM_PART = "/jsp/claim/dealerClaimMng/showRoItemParts.jsp";
	private final String RO_ITEM_OTHER = "/jsp/claim/dealerClaimMng/showRoItemOthers.jsp";
	private final String SHOW_CODE_URL = "/jsp/claim/dealerClaimMng/showCode.jsp"; 
	
	/*****zhumingwei 2011-02-12******/
	private final String SHOW_CODE_URL111 = "/jsp/claim/dealerClaimMng/showCode111.jsp"; 
	/*****zhumingwei 2011-02-12******/
	
	private final String SHOW_SUPPLIER_URL = "/jsp/claim/dealerClaimMng/showSupplier.jsp";
	
	private final String INFO_URL = "/jsp/infomationQuality/infomationQualityMaintain.jsp";// 主页面（查询）
	private final String INFO_ADD_URL = "/jsp/infomationQuality/infomationQualityAdd.jsp";// 增加页面
	private final String INFO_DETAIL_URL = "/jsp/infomationQuality/infomationQualityDetail.jsp";// 修改页面
	
	private final String ACTIVITY_URL = "/jsp/claim/dealerClaimMng/showActivity.jsp";
	
    private final String MAINTAIN_HIS_URL = "/jsp/claim/application/maintainHistory.jsp";//维修历史信息页面
    private final String AUDITING_HIS_URL = "/jsp/claim/application/auditingHistory.jsp";//授权历史记录信息页面
    private final String FREEMAINTAIM_HIS_URL = "/jsp/claim/application/freeMaintainHistory.jsp";//保养历史记录
    private final String QUALITY_URL="/jsp/claim/dealerClaimMng/qualitycheck.jsp";//质量信息卡页面
    private final String QUALITY_SERCH_URL="/jsp/claim/dealerClaimMng/qualityModify.jsp";//质量信息卡修改查询
    
    private final String MAINTAIN_STATE_SET_URL = "/jsp/claim/dealerClaimMng/maintainStateSet.jsp" ;//保养状态判定页面
    private final String THREE_PACKAGE_SET_URL = "/jsp/claim/dealerClaimMng/threePackageSet.jsp" ;//配件三包判定页面

    private final String RULE_PARTCODE_URL = "/jsp/vehicleInfoManage/apply/showRuleListPartCode.jsp";// 配件选择
    
    
	public void chooseRoForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {

			act.setForword(RO_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: claimBillForword
	 * @Description: TODO(索赔单主页跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void claimBillForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {

			act.setForword(CLAIM_BILL_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: claimBillAddForword
	 * @Description: TODO(索赔但新增页面跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void claimBillAddForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		String phone="";
		try {
			TmDealerPO tdp = new TmDealerPO();
			TtAsActivityPO activity = new TtAsActivityPO();
			tdp.setDealerId(Utility.getLong(dealerId));
			List<TmDealerPO> lsd = dao.select(tdp);
			if (lsd != null) {
				if (lsd.size() > 0) {
					tdp = lsd.get(0);
				}
			}

			RequestWrapper request = act.getRequest();
			//以下注释 的7次与数据库的交互在功能中没有用到
//			act.setOutData("BUSINESS_CHNG_CODE_01",
//					getChngCodeStr(Constant.BUSINESS_CHNG_CODE_01)); // 质损程度
//			act.setOutData("BUSINESS_CHNG_CODE_02",
//					getChngCodeStr(Constant.BUSINESS_CHNG_CODE_02));// 质损区域
//			act.setOutData("BUSINESS_CHNG_CODE_03",
//					getChngCodeStr(Constant.BUSINESS_CHNG_CODE_03));// 质损类型
//			act.setOutData("BUSINESS_CHNG_CODE_04",
//					getChngCodeStr(Constant.BUSINESS_CHNG_CODE_04));// 故障代码
//			getBrand();
//			getSeries();
//			getModel();
			if(tdp.getPhone()!=null&&!tdp.getPhone().equals("")){
				phone=tdp.getPhone();
			}
			act.setOutData("OTHERFEE", getOtherfeeStr());
			act.setOutData("dealerName", tdp.getDealerName());
			act.setOutData("dealerCode", tdp.getDealerCode());
			act.setOutData("phone", phone);
			//act.setOutData("ACTIVITYCOMBO", getActivityStr());
			List<TtAsWrGamefeePO> lst = daom.queryGuaranteeAmount(null, null,
					-1l, null);
			act.setOutData("FEE", lst);

			act.setForword(CLAIM_BILL_ADD_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: claimBillModifyForword
	 * @Description: TODO(索赔单修改页面跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void claimBillModifyForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		Long provinceId = null;
		String phone = "";

		try {
			RequestWrapper request = act.getRequest();
			TtAsActivityPO activity = new TtAsActivityPO();
			String id = request.getParamValue("ID");
			List resList = daom.queryDealerById(Utility.getLong(logonUser
					.getDealerId()));
			if (resList != null && resList.size() > 0) {
				TmDealerPO dealerPO = (TmDealerPO) resList.get(0);
				phone = dealerPO.getPhone();
				provinceId = dealerPO.getProvinceId();
			}
			TtAsWrApplicationExtPO tawep = dao.queryApplicationById(id);
			List<ClaimListBean> partls = dao.queryPartById(id); // 取配件信息
			List<ClaimListBean> itemls = dao.queryItemById(id); // 取工时
			List<TtAsWrNetitemExtPO> otherls = dao.queryOtherByid(id);// 取其他项目
			List feeType = dao.getFeeType(Constant.FEE_STATUS.toString());// 保养类型列表
			List<FsFileuploadPO> attachLs = dao.queryAttById(id);// 取得附件
			act.setOutData("OTHERFEE", getOtherfeeStr());
			act.setOutData("application", tawep);

			if (tawep != null) {
				List<TtAsWrGamefeePO> lst = daom.queryGuaranteeAmount(tawep
						.getPurchasedDate(), provinceId, tawep.getModelId(),
						companyId);
				act.setOutData("FEE", lst);
				if (Constant.CLA_TYPE_06.equals(tawep.getClaimType())) {
					List<TtAsActivityPO> ls = dao.queryActivity(tawep.getId());
					if (ls != null) {
						if (ls.size() > 0) {

							activity = ls.get(0);

						}
					}

				}
			}
			List<Map<String,Object>> jc = dao.queryTcCode();
			int jc_1 = 0;
			if(jc.size()>0){
				jc_1 = Integer.valueOf(jc.get(0).get("CODE_ID").toString());
			}
			act.setOutData("JC_1", jc_1);
			act.setOutData("ACTIVITY", activity);
			act.setOutData("FEETYPE", feeType);// 查询动态列的集合
			act.setOutData("ID", id);
			act.setOutData("itemLs", itemls);
			act.setOutData("partLs", partls);
			act.setOutData("otherLs", otherls);
			act.setOutData("attachLs", attachLs);
			act.setOutData("phone", phone);
			act.setForword(CLAIM_BILL_MODIFY_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: getDetailByVinForward
	 * @Description: TODO(选择VIN带出车辆信息跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getDetailByVinForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			act.setForword(SHOW_VIN_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}
	
    public void getQualityCard(){
    	ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String claimId = request.getParamValue("claimId");
			TtAsWrInformationqualityPO po=dao.getQualityCard(claimId);
			act.setOutData("po", po);
			act.setForword(QUALITY_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}
    
    public void qualitySerch(){
    	ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String claimId = request.getParamValue("claimId");
			TtAsWrInformationqualityPO po=dao.getQualityCard(claimId);
			act.setOutData("po", po);
			act.setOutData("claimId",claimId);
			act.setForword(QUALITY_SERCH_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
    }
    
    public void qualityModify(){
    	ActionContext act = ActionContext.getContext();
    	AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
    	try{
    		RequestWrapper request = act.getRequest();
    		TtAsWrInformationqualityPO po=new TtAsWrInformationqualityPO();
    		String id = request.getParamValue("id");
    		String caseWork = request.getParamValue("caseWork");
    		String questionCase = request.getParamValue("questionCase");
    		String conntion = request.getParamValue("conntion");
    		String dutyUnit = request.getParamValue("dutyUnit");
    		String tempStep = request.getParamValue("tempStep");
    		String forveStep = request.getParamValue("forveStep");
    		String suggest = request.getParamValue("suggest");
    		String serviceOpinion = request.getParamValue("serviceOpinion");
    		po.setId(Long.parseLong(id));
    		po.setCaseWork(caseWork);
    		po.setQuestionCase(questionCase);
    		po.setConntion(conntion);
    		po.setDutyUnit(dutyUnit);
    		po.setTempStep(tempStep);
    		po.setForveStep(forveStep);
    		po.setSuggest(suggest);
    		po.setServiceOpinion(serviceOpinion);
    		po.setUpdateBy(logonUser.getUserId());
    		po.setUpdateDate(new Date());
    		dao.qualityUpdate(po);
    		act.setOutData("flag",true);
    	}catch(Exception e){
    		BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
    	}
    }

	/**
	 * 
	 * @Title: selectMainTimeForward
	 * @Description: TODO(选择主工时页面跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void selectMainTimeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roNo = request.getParamValue("roNo");
			String vin = request.getParamValue("vin");
			String treeCode = request.getParamValue("TREE_CODE");
			String id = request.getParamValue("timeId"); // 主页面中的主工时代码
			String timeCode = request.getParamValue("timeCode");
			String modelId = request.getParamValue("MODEL_ID");
			act.setOutData("roNo", roNo);
			act.setOutData("vin", vin);
			act.setOutData("timeId", id);
			act.setOutData("timeCode", timeCode);
			act.setOutData("TREE_CODE", treeCode);
			act.setOutData("modelId", modelId);
			act.setOutData("GROUP", getGroupNameStr());
			act.setForword(MAIN_TIME_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: selectTimeForward
	 * @Description: TODO(选择工时页面跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void selectTimeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String treeCode = request.getParamValue("TREE_CODE");
			String id = request.getParamValue("timeId"); // 主页面中的主工时代码
			String timeCode = request.getParamValue("timeCode");
			String modelId = request.getParamValue("MODEL_ID");
			act.setOutData("timeId", id);
			act.setOutData("timeCode", timeCode);
			act.setOutData("TREE_CODE", treeCode);
			act.setOutData("modelId", modelId);
			act.setOutData("GROUP", getGroupNameStr());
			act.setForword(TIME_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: selectMainPartCodeForward
	 * @Description: TODO(选择主配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void selectMainPartCodeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roNo = request.getParamValue("roNo");
			String vin = request.getParamValue("vin");
			String groupId = request.getParamValue("GROUP_ID");
			act.setOutData("roNo", roNo);
			act.setOutData("vin", vin);
			act.setOutData("GROUP_ID", groupId);
			act.setForword(MAIN_PARTCODE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: selectPartCodeForward
	 * @Description: TODO(上件选择跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void selectPartCodeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String groupId = request.getParamValue("GROUP_ID");
			act.setOutData("GROUP_ID", groupId);
			act.setForword(PARTCODE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: selectDownPartCodeForward
	 * @Description: TODO(下件选择跳转)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void selectDownPartCodeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String groupId = request.getParamValue("GROUP_ID");
			String PartCode = request.getParamValue("partCode");
			act.setOutData("GROUP_ID", groupId);
			act.setOutData("PartCode", PartCode);
			act.setForword(DOWN_PARTCODE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: getDetailByVin
	 * @Description: TODO(根据VIN和车主姓名查询车辆信息表)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getDetailByVin() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		StringBuffer con = new StringBuffer();
		Map<String, String> map = new HashMap<String, String>();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			String vin = request.getParamValue("VIN_PARAM");
			String customer = request.getParamValue("CUSTOMER");
			String vinParent = request.getParamValue("vinParent");
			map.put("dealerId", dealerId);
			map.put("vin", vin);
			map.put("vinParent", vinParent);
			map.put("customer", customer);
			map.put("companyId", companyId.toString());
			PageResult<TmVehicleExtPO> ps = dao.getVin(map, pageSize, curPage);
			List<Map<String, Object>> list = dao.getVinUserName(vinParent);
			act.setOutData("list", list);
			List<Map<String, Object>> list1 = dao.getGuranteeCode(vinParent);
			if(list1.size()>0){
			act.setOutData("list1", list1.get(0));
			}else{
				act.setOutData("list1", 0);	
			}
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	

	/**
	 * 
	 * @Title: queryTime
	 * @Description: TODO(弹出框查询工时)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void queryTime() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			String timeCode = request.getParamValue("timeCode");
			String treeCode = request.getParamValue("TREE_CODE");
			String id = request.getParamValue("timeId"); // 主页面中的主工时代码
			String roNo = request.getParamValue("roNo"); // 工单号
			String vin = request.getParamValue("vin"); // 车辆VIN
			//String modelId = request.getParamValue("MODEL_ID");
			Long id0 = null;
			TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
			if (Utility.testString(id)) {
				/*
				 * tawlp.setLabourId(Utility.getLong(id)); List<TtAsWrLabouritemPO>
				 * temp0 = dao.select(tawlp); //通过labour_id取labour_code if
				 * (temp0!=null) { if (temp0.size()>0) { tawlp = temp0.get(0); } }
				 * id=tawlp.getWrLabourcode();
				 */
				TtAsWrWrlabinfoPO tawp = new TtAsWrWrlabinfoPO();
				tawp.setLabourCode(id); //
				List<TtAsWrWrlabinfoPO> temp = dao.select(tawp);// 通过labour_code取工时信息表中的id
				if (temp != null) {
					if (temp.size() > 0) {
						tawp = temp.get(0);
					}
				}
				id0 = tawp.getId();
			} else {

			}

			act.setOutData("timeId", id);
			act.setOutData("TREE_CODE", treeCode);
			String modelId = request.getParamValue("WRGROUP_ID");//取道的是车型
			String wrgroupId = request.getParamValue("WRGROUP_ID"); // 取道的是车型
			TtAsWrModelItemPO tawmip = new TtAsWrModelItemPO();
			if (Utility.testString(wrgroupId)) {
				// tawmip.setModelId(Utility.getLong(wrgroupId));
				List<TtAsWrModelItemPO> wLs = dao.getWgroupId(wrgroupId);
				if (wLs != null) {
					if (wLs.size() > 0) {
						tawmip = wLs.get(0);
						wrgroupId = tawmip.getWrgroupId().toString();
					} else {
						wrgroupId = "-1"; // 使其没有车型组
					}
				} else {
					wrgroupId = "-1"; // 使其没有车型组
				}
			}

			String labourCode = request.getParamValue("LABOUR_CODE"); // 查询页面中的查询条件工时代码
			String cnDes = request.getParamValue("CN_DES");

			/*
			 * if (dealerId!=null){ con.append(" and v.DEALER_ID = "+dealerId+"
			 * "); }
			 */
			// 主维修工时
			if (Utility.testString(treeCode)) {
				con.append(" and T.TREE_CODE = '" + treeCode + "' ");
			}
			if (id0 != null || "4".equals(treeCode)) {
				con
						.append(" AND T.ID IN (select add_id from TT_AS_WR_ADDITIONALITEM where w_id="
								+ id0 + ") ");
			}
			// if (Utility.testString(wrgroupId)) {
			con.append(" and G.WRGROUP_ID = " + wrgroupId + " ");
			// }
			if (Utility.testString(labourCode)) {
				con.append(" and t.LABOUR_CODE LIKE '%" + labourCode + "%' ");
			}
			if (Utility.testString(cnDes)) {
				con.append(" and t.CN_DES LIKE '%" + cnDes + "%' ");
			}
			PageResult<TtAsWrWrlabinfoExtPO> ps = dao.queryTime(logonUser, con
					.toString(), roNo, vin, modelId,companyId.toString(),pageSize, curPage);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: queryPartCode
	 * @Description: TODO(查询配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void queryPartCode1() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Map<String, String> map = new HashMap<String, String>();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			String roNo = request.getParamValue("roNo");
			String vin = request.getParamValue("vin");
			String groupId = request.getParamValue("GROUP_ID"); // 车型
			String partCode = request.getParamValue("PART_CODE");
			String downpartCode = request.getParamValue("DOWN_PART_CODE");
			String partName = request.getParamValue("PART_NAME"); // 主页面中的主工时代码
			String supplierName = request.getParamValue("SUPPLIER_NAME");
			map.put("roNo", roNo);
			map.put("vin", vin);
			map.put("partCode", partCode);
			map.put("partName", partName);
			map.put("groupId", groupId);
			map.put("companyId", companyId.toString());
			map.put("supplierName", supplierName);
			PageResult<TmPtPartBaseExtPO> ps = dao.queryPartCode1(logonUser,
					map, pageSize, curPage,downpartCode);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	public void queryPartCode() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Map<String, String> map = new HashMap<String, String>();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			String roNo = request.getParamValue("roNo");
			String vin = request.getParamValue("vin");
			String groupId = request.getParamValue("GROUP_ID"); // 车型
			String partCode = request.getParamValue("PART_CODE");
			String downpartCode = request.getParamValue("DOWN_PART_CODE");
			String partName = request.getParamValue("PART_NAME"); // 主页面中的主工时代码
			String supplierName = request.getParamValue("SUPPLIER_NAME");
			map.put("roNo", roNo);
			map.put("vin", vin);
			map.put("partCode", partCode);
			map.put("partName", partName);
			map.put("groupId", groupId);
			map.put("companyId", companyId.toString());
			map.put("supplierName", supplierName);
			PageResult<TmPtPartBaseExtPO> ps = dao.queryPartCode(logonUser,
					map, pageSize, curPage);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: selectCodeForward 
	* @Description: TODO(跳转代码选择页面) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void selectCodeForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String type = request.getParamValue("type");
			String labourCode = request.getParamValue("labourCode");
			act.setOutData("labourCode", labourCode);
			act.setOutData("type", type);
			act.setForword(SHOW_CODE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}
	
	/**
	 * zhumingwei 2011-02-12
	 */
	public void selectCodeForward111() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String type = request.getParamValue("type");
			String labourCode = request.getParamValue("labourCode");
			List<Map<String, Object>> list = dao.selectCode();
			act.setOutData("list", list);
			act.setOutData("labourCode", labourCode);
			act.setOutData("type", type);
			act.setForword(SHOW_CODE_URL111);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}
	
	/**
	 * 
	* @Title: selectSupplierForward 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void selectSupplierForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String partCode = request.getParamValue("partCode");
			act.setOutData("partCode", partCode);
			act.setForword(SHOW_SUPPLIER_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}
	/**
	 * 
	* @Title: querySupplier 
	* @Description: TODO(查询配件经销商) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void querySupplier() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			RequestWrapper request = act.getRequest();
			String type = request.getParamValue("type");
			String partCode = request.getParamValue("partCode"); //配件代码
			String supplierCode = request.getParamValue("SUPPLIER_CODE"); //供应商代码
			String supplierName = request.getParamValue("SUPPLIER_NAME"); //供应商名称
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Map<String,String> map = new HashMap<String,String>();
			map.put("partCode", partCode);
			map.put("companyId", companyId.toString());
			map.put("supplierCode", supplierCode);
			map.put("supplierName", supplierName);
			List<Map<String, Object>> supplierList = dao.viewSupplier(partCode);
		    int len = 0;
			if(supplierList.size()>0){
				len=1;
			}
			map.put("len", String.valueOf(len));
			PageResult<TmPtSupplierPO> ps = dao.querySupplier(map, curPage, Constant.PAGE_SIZE);
			act.setOutData("partCode", partCode);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}
	/**
	 * 
	* @Title: getChngCode 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void getChngCode() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String type = request.getParamValue("type");
			String labourCode = request.getParamValue("labourCode");
			String code = request.getParamValue("CODE");
			String codeName = request.getParamValue("CODE_NAME");
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			if ("1".equals(type)) {
				act.setOutData("ps",getChngCodeList(Constant.BUSINESS_CHNG_CODE_01,code,codeName,curPage,Constant.PAGE_SIZE)); //质损程度
			}else if  ("2".equals(type)) {
			act.setOutData("ps",getChngCodeList(Constant.BUSINESS_CHNG_CODE_02,code,codeName,curPage,Constant.PAGE_SIZE));// 质损区域
			}else if  ("3".equals(type)) {
			act.setOutData("ps",getChngCodeList(Constant.BUSINESS_CHNG_CODE_03,code,codeName,curPage,Constant.PAGE_SIZE));// 质损类型
			}else if  ("4".equals(type)) {
				if (Utility.testString(labourCode)) {
					act.setOutData("ps",dao.queryPartCodeByItemId(Constant.BUSINESS_CHNG_CODE_04,labourCode,code,codeName,curPage,Constant.PAGE_SIZE)); //质损程度
				}else {
					act.setOutData("ps",getChngCodeList(Constant.BUSINESS_CHNG_CODE_04,code,codeName,curPage,Constant.PAGE_SIZE)); //质损程度
					
				}
			}
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	//zhumingwei 2011-02-12
	public void getChngCode111() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String type = request.getParamValue("type");
			String labourCode = request.getParamValue("labourCode");
			String code = request.getParamValue("CODE");
			String codeName = request.getParamValue("CODE_NAME");
			String CUSTOMERS_PROBLEM = request.getParamValue("CUSTOMERS_PROBLEM");
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			if ("5".equals(type)) {
				act.setOutData("ps",getChngCodeList111(code,codeName,CUSTOMERS_PROBLEM,curPage,Constant.PAGE_SIZE));
			}
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	//zhumingwei 2011-03-08
	public void queryCon(){
		ActionContext act = ActionContext.getContext();
		RequestWrapper request = act.getRequest();
		String code = request.getParamValue("code");
		List<Map<String, Object>> list = dao.queryCon(code);
		act.setOutData("list", list);
	}
	
	/**
	 * 
	* @Title: getChngCode 
	* @Description: TODO(根据类型返回故障代码，质损区域，质损类型，质损程度) 
	* @param @param type
	* @param @return    设定文件 
	* @return List<TmBusinessChngCodePO>    返回类型 
	* @throws
	 */
	public PageResult<TmBusinessChngCodePO> getChngCodeList(int type,String code,String codeName,int curPage,int pageSize) {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		
		PageResult<TmBusinessChngCodePO> seriesList = dao.queryChngCodeByType(type,companyId,code,codeName,curPage,pageSize);
		return seriesList;
	}
	
	//zhumingwei 2011-02-12
	public PageResult<Map<String, Object>> getChngCodeList111(String code,String codeName,String CUSTOMERS_PROBLEM,int curPage,int pageSize) {
		PageResult<Map<String, Object>> ps = dao.queryChngCodeByType111(code,codeName,CUSTOMERS_PROBLEM,curPage,pageSize);
		return ps;
	}

	/**
	 * 
	 * @Title: getChngCodeStr
	 * @Description: TODO(取得故障代码，质损区域，质损类型，质损程度下拉框)
	 * @param
	 * @param type
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getChngCodeStr(int type) {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		List<TmBusinessChngCodePO> seriesList = dao.queryChngCodeByType(type,
				companyId,null,null);
		String retStr = "";
		// retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			TmBusinessChngCodePO bean = new TmBusinessChngCodePO();
			bean = (TmBusinessChngCodePO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getCode() + "\' title=\'"
					+ bean.getCodeName() + "\'>" + bean.getCodeName()
					+ "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getOtherfeeStr
	 * @Description: TODO(取得其他费用下拉框)
	 * @param
	 * @param type
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getOtherfeeStr() {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);

		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		List<TtAsWrOtherfeePO> seriesList = dao.queryOtherFee(companyId);
		String retStr = "";
		retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			TtAsWrOtherfeePO bean = new TtAsWrOtherfeePO();
			bean = (TtAsWrOtherfeePO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getFeeCode() + "\'"
					+ "title=\'" + bean.getFeeName() + "\'>"
					+ bean.getFeeCode() + "-" + bean.getFeeName() + "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getOtherfeeStr
	 * @Description: TODO()
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getActivityStr() {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		List<TtAsActivityPO> seriesList = dao.queryActivityCombo();
		String retStr = "";
		retStr += "<option value=\',0,\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			TtAsActivityPO bean = new TtAsActivityPO();
			bean = (TtAsActivityPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getActivityCode() + ","
					+ bean.getActivityFee() + "," + bean.getIsFixfee() + "\'>"
					+ bean.getActivityName() + "</option>";
		}
		return retStr;
	}
	/**
	 * 
	* @Title: getActivityStr 
	* @Description: TODO(根据车型ID查询服务活动) 
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public void getActivityStrById() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		RequestWrapper request = act.getRequest();
		String modelId = request.getParamValue("modelId");
		List<TtAsActivityPO> seriesList = dao.queryActivityCombo(modelId);
		String retStr = "";
		retStr += "<option value=\',0,\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			TtAsActivityPO bean = new TtAsActivityPO();
			bean = (TtAsActivityPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getActivityCode() + ","
					+ bean.getActivityFee() + "," + bean.getIsFixfee() + "\'>"
					+ bean.getActivityName() + "</option>";
		}
		act.setOutData("activity", retStr);
	}
	
	/**
	 * 
	 * @Title: changeItem
	 * @Description: TODO(选择工时会使故障代码联动)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeItem() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			// 取得ITEM_ID
			String itemId = request.getParamValue("ITEM_ID");
			// String partName = request.getParamValue("PART_NAME"); //
			// 主页面中的主工时代码
			List<TmBusinessChngCodePO> seriesList = dao.queryPartCodeByItemId(
					Constant.BUSINESS_CHNG_CODE_04, itemId,null,null);
			String retStr = "";
			// retStr += "<option value=\'\'>-请选择-</option>";
			for (int i = 0; i < seriesList.size(); i++) {
				TmBusinessChngCodePO bean = new TmBusinessChngCodePO();
				bean = (TmBusinessChngCodePO) seriesList.get(i);
				retStr += "<option value=\'" + bean.getCode() + "\' title=\'"
						+ bean.getCodeName() + "\'>" + bean.getCodeName()
						+ "</option>";
			}
			// 如果工时没有对应故障代码则显示全部故障代码
			if (seriesList.size() == 0) {
				retStr = getChngCodeStr(Constant.BUSINESS_CHNG_CODE_04);
			}
			act.setOutData("changeCode", retStr);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}
	/**
	 * 
	* @Title: changeOtherFore 
	* @Description: TODO(选择其他项目后带出是否已经授权) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void changeOtherFore() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			RequestWrapper request = act.getRequest();
			String itemCode = request.getParamValue("itemCode"); // 其他项目代码
			String roNo = request.getParamValue("roNo");
			String vin = request.getParamValue("vin");
			Map<String,String> map =new HashMap();
			map.put("companyId", companyId.toString());
			map.put("itemCode", itemCode);
			map.put("roNo", roNo);
			map.put("vin", vin);
			List<TtAsWrOtherfeePO> ls= dao.changeOtherFore(map);
			int count = 0;
			TtAsWrOtherfeePO tawop = new TtAsWrOtherfeePO();
			if(ls!=null) {
				if (ls.size()>0) {
					tawop = ls.get(0);
					count = tawop.getIsDel();
				}
			}
			act.setOutData("count",count);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: changeFree
	 * @Description: TODO(选择VIN后根据车型ID联动免费保养次数下拉框)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeFree() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		Long provinceId = null;
		StringBuffer con = new StringBuffer();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			List resList = daom.queryDealerById(Utility.getLong(logonUser
					.getDealerId()));
			if (resList != null && resList.size() > 0) {
				TmDealerPO dealerPO = (TmDealerPO) resList.get(0);
				provinceId = dealerPO.getProvinceId();
			}
			// 取得ITEM_ID
			String modelId = request.getParamValue("MODEL_ID");
			Long modelIdLong = Utility.getLong(modelId);
			String purchasedDateStr = request.getParamValue("PURCHASED_DATE");
			Date purchasedDate = Utility.getDate(purchasedDateStr, 3);
			// String partName = request.getParamValue("PART_NAME"); //
			// 主页面中的主工时代码
			List<TtAsWrGamefeePO> seriesList = daom.queryGuaranteeAmount(
					purchasedDate, provinceId, modelIdLong, companyId);
			// List<TmBusinessChngCodePO> seriesList =
			// dao.queryPartCodeByItemId(
			// Constant.BUSINESS_CHNG_CODE_04, itemId);
			String retStr = "";
			retStr += "<option value=\'0\'>-请选择-</option>";
			if (seriesList != null) {
				for (int i = 0; i < seriesList.size(); i++) {
					TtAsWrGamefeePO bean = new TtAsWrGamefeePO();
					bean = (TtAsWrGamefeePO) seriesList.get(i);
					retStr += "<option value=\'" + bean.getManintainFee()
							+ "\'>" + bean.getMaintainfeeOrder() + "</option>";
				}
			}
			/*
			 * // 如果工时没有对应故障代码则显示全部故障代码 if (seriesList.size() == 0) { retStr =
			 * getChngCodeStr(Constant.BUSINESS_CHNG_CODE_04); }
			 */
			act.setOutData("changeFree", retStr);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: changeFreeText
	 * @Description: TODO(在隐藏于设置免费保养次数以及免费保养费用)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeFreeText() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		Long provinceId = null;
		StringBuffer con = new StringBuffer();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			List resList = daom.queryDealerById(Utility.getLong(logonUser
					.getDealerId()));
			if (resList != null && resList.size() > 0) {
				TmDealerPO dealerPO = (TmDealerPO) resList.get(0);
				provinceId = dealerPO.getProvinceId();
			}
			// 取得ITEM_ID
			String modelId = request.getParamValue("MODEL_ID");
			Long modelIdLong = Utility.getLong(modelId);
			String purchasedDateStr = request.getParamValue("PURCHASED_DATE");
			String vin = request.getParamValue("VIN");
			List<Map<String, Object>> modelList = dao.viewModelId(vin);
			//Date purchasedDate = Utility.getDate(purchasedDateStr, 1);
			// String partName = request.getParamValue("PART_NAME"); //
			// 主页面中的主工时代码
			//List<TtAsWrGamefeePO> seriesList = daom.queryGuaranteeAmount(
			//		purchasedDate, provinceId, modelIdLong, companyId);
			List<TtAsWrGamefeePO> seriesList = daom.queryGuaranteeAmount(modelIdLong);
			List<Map<String, Object>> freeList = daom.viewFreeModel(vin);
			String retStr = "";
			String fee = "";
			String feeOrder = "";
			//这里判定此次保养是否同意费用选项。。。
			String roNo = request.getParamValue("ro_no");
			if(StringUtil.notNull(roNo)){
				TtAsRepairOrderPO po = new TtAsRepairOrderPO();
				po.setRoNo(roNo);
				List<TtAsRepairOrderPO> roList = dao.select(po);
				if(roList.size()>0){
					// 0代表同意给费用。。1 不同意费用
					if("1".equals(roList.get(0).getAccreditAmount().toString())&&Integer.valueOf(roList.get(0).getApprovalYn().toString())==1){
						act.setOutData("payment", true);
					}
				}
			}
			// retStr += "<option value=\'0\'>-请选择-</option>";
			if (freeList != null) {
				for (int i = 0; i < seriesList.size(); i++) {
					TtAsWrGamefeePO bean = new TtAsWrGamefeePO();
					bean = (TtAsWrGamefeePO) seriesList.get(i);
					fee += "," +freeList.get(0).get("FREE");
					feeOrder += "," + bean.getMaintainfeeOrder();
				}
				retStr = fee + "*" + feeOrder;
			}
			/*
			 * // 如果工时没有对应故障代码则显示全部故障代码 if (seriesList.size() == 0) { retStr =
			 * getChngCodeStr(Constant.BUSINESS_CHNG_CODE_04); }
			 */
			act.setOutData("changeFree", retStr);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: getGroupNameStr
	 * @Description: TODO(取得车型组下拉框)
	 * @param
	 * @param type
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getGroupNameStr() {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		List<TtAsWrModelGroupPO> seriesList = dao.queryGroupName();
		String retStr = "";
		// retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			TtAsWrModelGroupPO bean = new TtAsWrModelGroupPO();
			bean = (TtAsWrModelGroupPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getWrgroupId() + "\'>"
					+ bean.getWrgroupName() + "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getBrandStr
	 * @Description: TODO(品牌下拉框)
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getBrandStr() {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		List<VwMaterialGroupPO> seriesList = dao.queryBrand();
		String retStr = "";
		// retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			VwMaterialGroupPO bean = new VwMaterialGroupPO();
			bean = (VwMaterialGroupPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getBrandCode() + "\'>"
					+ bean.getBrandName() + "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getSeriesStr
	 * @Description: TODO(车系下拉框)
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getSeriesStr(String brand) {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		List<VwMaterialGroupPO> seriesList = dao.querySeries(brand);
		String retStr = "";
		// retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			VwMaterialGroupPO bean = new VwMaterialGroupPO();
			bean = (VwMaterialGroupPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getSeriesCode() + "\'>"
					+ bean.getSeriesName() + "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getModelStr
	 * @Description: TODO(车型下拉框)
	 * @param
	 * @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public String getModelStr(String series) {
		ActionContext ctx = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) ctx.getSession().get(
				Constant.LOGON_USER);
		List<VwMaterialGroupPO> seriesList = dao.queryModel(series);
		String retStr = "";
		// retStr += "<option value=\'\'>-请选择-</option>";
		for (int i = 0; i < seriesList.size(); i++) {
			VwMaterialGroupPO bean = new VwMaterialGroupPO();
			bean = (VwMaterialGroupPO) seriesList.get(i);
			retStr += "<option value=\'" + bean.getModelCode() + "\'>"
					+ bean.getModelName() + "</option>";
		}
		return retStr;
	}

	/**
	 * 
	 * @Title: getBrand
	 * @Description: TODO(取得品牌)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getBrand() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			act.setOutData("brand", getBrandStr());
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: getSeries
	 * @Description: TODO(取得车系)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getSeries() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String brandCode = request.getParamValue("BRAND_CODE");
			act.setOutData("series", getSeriesStr(brandCode));
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: getModel
	 * @Description: TODO(取得车型)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getModel() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String series = request.getParamValue("SERIES_CODE");
			act.setOutData("model", getModelStr(series));
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}

	/**
	 * 
	 * @Title: getActivityRepairs
	 * @Description: TODO(根据服务活动CODE取得维修项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getActivityRepairs() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			RequestWrapper request = act.getRequest();
			String code = request.getParamValue("CODE");
			String modelId = request.getParamValue("modelId");
			act.setOutData("activityRepairs", dao.queryActivityRepair(code,
					dealerId,modelId,companyId.toString()));
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: getActivityParts
	 * @Description: TODO(根据服务活动CODE取得配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getActivityParts() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			String code = request.getParamValue("CODE");
			String mileage = request.getParamValue("IN_MILEAGE");
			String vin = request.getParamValue("VIN");
			Double mileagedb = Utility.getDouble(mileage);
			act.setOutData("activityParts", dao.queryActivityPart(code,vin,mileagedb,
					dealerId));
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: getActivityOthers
	 * @Description: TODO(根据服务活动CODE取得其他项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void getActivityOthers() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			String code = request.getParamValue("CODE");
			act.setOutData("activityOthers", dao.queryActivityOther(code,
					dealerId));
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: applicationQuery
	 * @Description: TODO(查询索赔单)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void applicationQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Date date = new Date();
		Map<String, String> map = new HashMap<String, String>();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			String claimNo = request.getParamValue("CLAIM_NO");
			String roNo = request.getParamValue("RO_NO");
			String lineNo = request.getParamValue("LINE_NO");
			String claimType = request.getParamValue("CLAIM_TYPE");
			String vin = request.getParamValue("VIN");
			String roStartdate = request.getParamValue("RO_STARTDATE");
			String roEnddate = request.getParamValue("RO_ENDDATE");
			String status = request.getParamValue("STATUS");
			map.put("dealerId", dealerId);
			map.put("claimNo", claimNo);
			map.put("roNo", roNo);
			map.put("lineNo", lineNo);
			map.put("claimType", claimType);
			map.put("vin", vin);
			map.put("roStartdate", roStartdate);
			map.put("roEnddate", roEnddate);
			map.put("status", status);
			map.put("oemCompanyId", companyId.toString());

			PageResult<TtAsWrApplicationExtBean> ps = dao.queryApplication1(
					logonUser, map, null, 10, curPage);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: applicationInsert
	 * @Description: TODO(新增索赔)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void applicationInsert() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser);
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Date date = new Date();
		RequestWrapper request = act.getRequest();
		String roNo = request.getParamValue("RO_NO"); // 工单号
		boolean flag = DBLockUtil.lock(roNo, DBLockUtil.BUSINESS_TYPE_13);
		if(flag){
			try {
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			float labourHoursMain = 0f; // 基本工时数
			float reinForceHoursMain = 0f; // 附加工时数
			double stdHourAmount = 0; // 基本工时金额
			double reinHourAmount = 0; // 附加工时金额
			int partsCount = 0; // 总配件数
			double labourAmountMain = 0; // 总工时金额
			double partsAmountMain = 0; // 配件金额
			double netItemAmount = 0; // 其他项目金额
			double repairTotal = 0; // 索赔申请金额

			String roId = request.getParamValue("roId"); // 从工单带过来的roId:为提交时更新工单附属表使用

			String yieldly = request.getParamValue("YIELDLY"); // 产地
			String licenseNo = request.getParamValue("LICENSE_NO"); // 车牌号
			String brandCode = request.getParamValue("BRAND_CODE0"); // 品牌
			String brandName = request.getParamValue("BRAND_NAME0");
			String modelCode = request.getParamValue("MODEL_CODE0"); // 车型
			String modelName = request.getParamValue("MODEL_NAME0");
			String seriesCode = request.getParamValue("SERIES_CODE0");// 车系
			String seriesName = request.getParamValue("SERIES_NAME0");
			String engineNo = request.getParamValue("ENGINE_NO");
			String gearboxNo = request.getParamValue("GEARBOX_NO0"); // 变速箱
			String rearaxleNo = request.getParamValue("REARAXLE_NO0"); // 后桥
			String transferNo = request.getParamValue("TRANSFER_NO0"); // 分动器
			String  claimZhiSun= request.getParamValue("CLAIM_ZHISHUN");//質損類型
			//String roNo = request.getParamValue("RO_NO"); // 工单号
			String lineNo = request.getParamValue("LINE_NO");// 行号
			lineNo = "1";
			String roStartdate = request.getParamValue("RO_STARTDATE");// 工单开始时间
			String roEnddate = request.getParamValue("RO_ENDDATE");// 工单结束时间
			String guaranteeDate = request.getParamValue("GUARANTEE_DATE");// 保修开始时间
			String serveAdvisor = request.getParamValue("SERVE_ADVISOR");// 接待员
			String vin = request.getParamValue("VIN");// VIN
			String remark = request.getParamValue("APP_REMARK");// 申请备注
			String claimType = request.getParamValue("CLAIM_TYPE"); // 索赔类型
			String troubleDesc = request.getParamValue("TROUBLE_DESC");
			String troubleReason = request.getParamValue("TROUBLE_REASON");
			String repairMethod = request.getParamValue("REPAIR_METHOD");
			String inMileage = request.getParamValue("IN_MILEAGE");

			String campaignCode = request.getParamValue("CAMPAIGN_CODE"); // 服务活动代码
			String campaignFee = request.getParamValue("CAMPAIGN_FEE"); // 服务活动费用

			String isFixing = request.getParamValue("IS_FIX"); // 服务活动是否固定费用1为固定费用
			String IS_AUDIT = request.getParamValue("IS_AUDIT");//判断是否选着人工审核
			String freeMAmount = request.getParamValue("FREE_M_AMOUNT"); // 免费保养次数
			String freeMPrice = request.getParamValue("FREE_M_PRICE"); // 免费保养费用

			// 主工时
			String[] items = request.getParamValues("MAIN_ITEM"); // 工时选择的CHECKBOX
			String[] wrLabourCodes = request.getParamValues("WR_LABOURCODE"); // 获取工时代码
			String[] wrLabournames = request.getParamValues("WR_LABOURNAME"); // 获取工时名称
			String[] labourHours = request.getParamValues("LABOUR_HOURS"); // 获取工时数
			String[] labourPrices = request.getParamValues("LABOUR_PRICE"); // 获取工时单价
			String[] labourAmounts = request.getParamValues("LABOUR_AMOUNT"); // 获取工时金额
			//String[] damageType = request.getParamValues("DAMAGE_TYPE"); // 质损类型
			//String[] damageArea = request.getParamValues("DAMAGE_AREA"); // 质损区域
			//String[] damageDegree = request.getParamValues("DAMAGE_DEGREE"); // 质损程度
			String[] troubleCode = request.getParamValues("TROUBLE_CODE"); // 故障代码
			//String[] damageTypeName = request.getParamValues("DAMAGE_TYPE_NAME"); // 质损类型
			//String[] damageAreaName = request.getParamValues("DAMAGE_AREA_NAME"); // 质损区域
			//String[] damageDegreeName = request.getParamValues("DAMAGE_DEGREE_NAME"); // 质损程度
			String[] troubleCodeName = request.getParamValues("TROUBLE_CODE_NAME"); // 故障代码
			String[] itemIsFore = request.getParamValues("ITEM_IS_FORE"); //是否授权
			String[] itemPayType = request.getParamValues("PAY_TYPE_ITEM"); //付费类型
			String[] isClaim = request.getParamValues("IS_BAC"); //是否累加
			String[] labourHidden = request.getParamValues("LABOUR_HOURS_HI");
			
			/*****************zhumingwei 2011-02-12**************/
			String[] TROUBLE_TYPE_NAME = request.getParamValues("TROUBLE_TYPE_NAME");
			/*****************zhumingwei 2011-02-12**************/
	
			// 附加工时
			String[] bMlCode = request.getParamValues("B_ML_CODE");
			String[] wrLabourCodes0 = request.getParamValues("WR_LABOURCODE0"); // 获取工时代码
			String[] wrLabournames0 = request.getParamValues("WR_LABOURNAME0"); // 获取工时名称
			String[] labourHours0 = request.getParamValues("LABOUR_HOURS0"); // 获取工时数
			String[] labourPrices0 = request.getParamValues("LABOUR_PRICE0"); // 获取工时单价
			String[] labourAmounts0 = request.getParamValues("LABOUR_AMOUNT0"); // 获取工时金额

			String[] parts = request.getParamValues("PART");// 配件选择的CHECKBOX
			String[] partCodes = request.getParamValues("PART_CODE"); // 上件代码
			String[] partNames = request.getParamValues("PART_NAME"); // 上件名称
			String[] downPartCodes = request.getParamValues("DOWN_PART_CODE"); // 下件代码
			String[] downPartNames = request.getParamValues("DOWN_PART_NAME"); // 下件名称
			String[] quantitys = request.getParamValues("QUANTITY"); // 上件数量
			String[] prices = request.getParamValues("PRICE"); // 单价
			String[] amounts = request.getParamValues("AMOUNT"); // 数量
			String[] supplierCodes = request.getParamValues("PRODUCER_CODE");// 生产商代码
			String[] supplierNames = request.getParamValues("PRODUCER_NAME"); // 生产商名称
			String[] downSupplierCodes = request.getParamValues("PRODUCER_CODE1");// 生产商代码
			String[] downSupplierNames = request.getParamValues("PRODUCER_NAME1"); // 生产商名称
			String[] remarks = request.getParamValues("TROUB_DESC"); // 故障描述 yh 2010.11.29
			String[] appTime = request.getParamValues("appTime"); // 索赔工时
			String[] bMpCode = request.getParamValues("B_MP_CODE");// 所属主配件
			String[] partIsFore = request.getParamValues("PART_IS_FORE");//是否授权
			String[] partPayType = request.getParamValues("IS_BAC_PART");//付费类型
			String[] isGua = request.getParamValues("IS_GUA"); //是否三包
			
			String[] itemCodes = request.getParamValues("ITEM_CODE"); // 其他项目代码
			String[] itemNames = request.getParamValues("ITEM_NAME"); // 其他项目名称
			String[] itemAmounts = request.getParamValues("ITEM_AMOUNT");// 其他项目金额
			String[] itemRemarks = request.getParamValues("ITEM_REMARK");// 备注
			String[] otherIsFore = request.getParamValues("OTHER_IS_FORE");//是否授权
			String[] otherPayType = request.getParamValues("PAY_TYPE_OTHER");//付费类型
			String[] partClaim = request.getParamValues("IS_BAC_PART"); //是否累加
			
			String itemIds1 = request.getParamValue("itemIds1");
			String partIds1 = request.getParamValue("partIds1");
			String otherIds1 = request.getParamValue("otherIds1");

			if (Utility.getInt(claimType) == Constant.CLA_TYPE_01) { // 一般索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_02) {// 免费保养
				wrLabourCodes = null;
				wrLabourCodes0 = null;
				parts = null;
				itemCodes = null;
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_03) {// 追加索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_04) {// 重复修理索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_05) {// 零件索赔更换
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_06) {// 服务活动
				//如果此服务活动是送免费保养，刚置保养费用为0
				freeMPrice = null; // 免费保养费用
				
				if ("1".equals(isFixing)) { // 是固定费用
					wrLabourCodes = null;
					wrLabourCodes0 = null;
					parts = null;
					itemCodes = null;
				} else {// 不是固定费用
					// campaignCode = null; //服务活动代码
					campaignFee = null; // 服务活动费用
					isFixing = null; // 服务活动是否固定费用1为固定费用
				}
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_07) {// PDI索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_08) {// 保外索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			}else if (Utility.getInt(claimType) == Constant.CLA_TYPE_09) {//外出维修
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
				
			}
			
			Double campaignFeeDb = Utility.getDouble(campaignFee);
			Double freeMPriceDb = Utility.getDouble(freeMPrice);
			
			Long claimId = Utility.getLong(SequenceManager.getSequence("")); // 产生一个索赔ID
			String claimNo=""; //一家经销商产生的索赔单号是连续的
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_01) { 
				claimNo = Utility.GetBillNo("",logonUser.getDealerCode(),"WWX");
			}
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_02) { 
				claimNo = Utility.GetBillNo("",logonUser.getDealerCode(),"WBY");
			}
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_06) { // 服务活动
				claimNo = Utility.GetBillNo("",logonUser.getDealerCode(),"WFW");
			}
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_07) { // 售前维修
				claimNo = Utility.GetBillNo("",logonUser.getDealerCode(),"WSQ");
			}
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_09) { //外出维修
				claimNo = Utility.GetBillNo("",logonUser.getDealerCode(),"WWC");
			}
			 List<Map<String, Object>> listRo = dao.getRepairOrder(roId);
			
			TtAsWrApplicationPO tawap = new TtAsWrApplicationPO();
			tawap.setId(claimId);
			tawap.setClaimNo(claimNo);
		//add xiongchuan 20110222 防止串号情况产生
			if(listRo.size()>0){
				tawap.setDealerId(Long.valueOf(listRo.get(0).get("ID").toString()));
			}
			else{
				tawap.setDealerId(Utility.getLong(dealerId));
			}
			tawap.setRoNo(roNo);
			tawap.setLineNo(Utility.getInt(lineNo));
			tawap.setVin(vin);
			tawap.setRoStartdate(Utility.getDate(roStartdate, 1));
			tawap.setRoEnddate(Utility.getDate(roEnddate, 1));
			tawap.setGuaranteeDate(Utility.getDate(guaranteeDate, 1));
			tawap.setServeAdvisor(serveAdvisor);
			tawap.setClaimType(Utility.getInt(claimType));
			tawap.setLicenseNo(licenseNo);
			tawap.setBrandCode(brandCode);
			tawap.setBrandName(brandName);
			tawap.setModelCode(modelCode);
			tawap.setModelName(modelName);
			tawap.setSeriesCode(seriesCode);
			tawap.setSeriesName(seriesName);
			tawap.setEngineNo(engineNo);
			tawap.setGearboxNo(gearboxNo);
			tawap.setRearaxleNo(rearaxleNo);
			tawap.setTransferNo(transferNo);
			tawap.setYieldly(yieldly);
			tawap.setApplicationDel(Constant.RO_APP_STATUS_01.toString());
			tawap.setIsAudit(Integer.valueOf(IS_AUDIT));		
			if(claimZhiSun!=null&&!claimZhiSun.equals("")){
				tawap.setDegradationType(Integer.valueOf(claimZhiSun));
			}
			// tawap.setTroubleCode(troubleCode);
			// tawap.setDamageType(damageType);
			// tawap.setDamageArea(damageArea);
			// tawap.setDamageDegree(damageDegree);
			tawap.setCampaignCode(campaignCode); // 服务活动代码
			tawap.setIsFixing(Utility.getInt(isFixing)); // 是否固定费用1为固定
			tawap.setCampaignFee(Utility.getDouble(campaignFee)); // 服务活动费用
			
            tawap.setApplyCampaignFee(Utility.getDouble(campaignFee));//经销商申请服务活动费用金额
			tawap.setFreeMAmount((int) Utility.getDouble(freeMAmount)); // 免费保养次数
			/**addUser:xiongchuan  addDate:2010-12-14   ***/
			tawap.setBalanceCampaignFee(Utility.getDouble(campaignFee));//经销商结算服务活动费用总金额
			tawap.setBalanceFreeMAmount(Utility.getDouble(freeMAmount));//经销商结算保养费用总金额
			tawap.setApplyCampaignFee(Utility.getDouble(campaignFee));//经销商申请服务活动费用总金额
			tawap.setApplyFreeMAmount(Utility.getDouble(freeMAmount));//经销商申请保养费用总金额
			/**endUser:xiongchuan  endDate:2010-12-14   ***/
			
			//如果此工单不同意费用，则FREE_AMOUNT   BALANCE_AMOUNT均搞为0
			TtAsRepairOrderPO opo = new TtAsRepairOrderPO();
			opo.setRoNo(roNo);
			List<TtAsRepairOrderPO> oList = dao.select(opo);
			if(oList.size()>0){
				if("1".equals(oList.get(0).getAccreditAmount().toString())&&"1".equals(oList.get(0).getApprovalYn())){
					freeMPriceDb = 0d ;
					tawap.setFreeMAmount(0); // 免费保养次数
					tawap.setFreeMPrice(0d); // 免费保养费用
				}
			}
			
			tawap.setRemark(remark);
			tawap.setTroubleDesc(troubleDesc);
			tawap.setTroubleReason(troubleReason);
			tawap.setRepairMethod(repairMethod);
			tawap.setInMileage(Utility.getDouble(inMileage));
			tawap.setStatus(Constant.CLAIM_APPLY_ORD_TYPE_01);
			tawap.setOemCompanyId(companyId);
			tawap.setCreateBy(logonUser.getUserId());
			tawap.setCreateDate(date);
			

			// 插入时需要对车辆信息表中的车牌号进行更新
			if(Utility.testString(vin)){
			TmVehiclePO tvp = new TmVehiclePO();
			tvp.setVin(vin);
			TmVehiclePO tvpUp = new TmVehiclePO();
			tvpUp.setLicenseNo(licenseNo);
			tvpUp.setUpdateBy(logonUser.getUserId());
			tvpUp.setUpdateDate(date);
			dao.update(tvp, tvpUp);
			System.out.print("vin码不等于空======"+vin);
			}
			System.out.print("vin码=======================等于空======"+vin);
			// 主工时插入
			if (wrLabourCodes != null) {
				for (int i = 0; i < wrLabourCodes.length; i++) {
					/* if (i == 0) { */
					// 主工时数量和金额
					labourHoursMain += Utility.getFloat(labourHours[i]);
					stdHourAmount += Utility.getDouble(labourAmounts[i]);
					/*
					 * } else { // 累加附加工时数量和金额 reinForceHoursMain +=
					 * Utility.getFloat(labourHours[i]); reinHourAmount +=
					 * Utility.getDouble(labourAmounts[i]); }
					 */
					// 累加总工时金额
					labourAmountMain += Utility.getDouble(labourAmounts[i]);
					TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
					// if (i == 0) {
					tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE);
					// } else {
					// tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE);
					// }
					if (appTime!=null) {
						for (int z=0;z<appTime.length;z++) {
							if (wrLabourCodes[i].equals(appTime[z])) { //配件中是这个工时的
								tawlp.setFirstPart(partCodes[z]);
								break;
							}
						}
					}
					
					tawlp.setId(claimId);
					tawlp.setLabourId(Utility.getLong(SequenceManager
							.getSequence("")));
					tawlp.setTroubleCode(troubleCode[i]);
					//tawlp.setDamageArea(damageArea[i]);
					//tawlp.setDamageDegree(damageDegree[i]);
					//tawlp.setDamageType(damageType[i]);
					tawlp.setTroubleCodeName(troubleCodeName[i]);
					//tawlp.setDamageAreaName(damageAreaName[i]);
					//tawlp.setDamageDegreeName(damageDegreeName[i]);
					//tawlp.setDamageTypeName(damageTypeName[i]);
					tawlp.setTroubleType(TROUBLE_TYPE_NAME [i]);
					tawlp.setWrLabourcode(wrLabourCodes[i]);
					tawlp.setWrLabourname(wrLabournames[i]);
					tawlp.setLabourHours(Utility.getFloat(labourHours[i]));
					tawlp.setLabourPrice(Utility.getFloat(labourPrices[i]));
					tawlp.setLabourAmount(Utility.getDouble(labourAmounts[i]));
					tawlp.setBalanceAmount(Utility.getDouble(labourAmounts[i]));
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawlp.setBalancePrice(Utility.getDouble(labourPrices[i]));
					tawlp.setApplyPrice(Utility.getDouble(labourPrices[i]));
					tawlp.setApplyQuantity(Utility.getDouble(labourHours[i]));
					tawlp.setApplyAmount(Utility.getDouble(labourAmounts[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					if("on".equals(itemIsFore)){
						tawlp.setIsFore(1); //授权
					}
					tawlp.setBalanceQuantity(Utility.getFloat(labourHours[i]));
					tawlp.setPayType(Utility.getInt(itemPayType[i]));
					tawlp.setIsClaim(Utility.getInt(isClaim[i]));
					tawlp.setLabourQuantityHidden(Utility.getDouble(labourHidden[i]));
					tawlp.setCreateBy(logonUser.getUserId());
					tawlp.setCreateDate(date);
					tawap.setLabourPrice(Utility.getDouble(labourPrices[i]));
					//if(claimNo!=null&&!claimNo.endsWith("")){
						dao.insert(tawlp);
					//}
					
					// System.out.println("==========="+wrLabourCodes[i]+"================");
				}
			}

			// 附加工时插入
			if (wrLabourCodes0 != null) {
				for (int i = 0; i < wrLabourCodes0.length; i++) {
					/*
					 * if (i == 0) { // 主工时数量和金额 labourHoursMain =
					 * Utility.getFloat(labourHours0[i]); stdHourAmount =
					 * Utility.getDouble(labourAmounts0[i]); } else {
					 */
					// 累加附加工时数量和金额
					reinForceHoursMain += Utility.getFloat(labourHours0[i]);
					reinHourAmount += Utility.getDouble(labourAmounts0[i]);
					/* } */
					// 累加总工时金额
					labourAmountMain += Utility.getDouble(labourAmounts0[i]);
					TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
					/*
					 * if (i == 0) {
					 * tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE); } else {
					 */
					tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE);
					/* } */
					tawlp.setId(claimId);
					tawlp.setLabourId(Utility.getLong(SequenceManager
							.getSequence("")));
					tawlp.setBMlCode(bMlCode[i]);
					tawlp.setWrLabourcode(wrLabourCodes0[i]);
					tawlp.setWrLabourname(wrLabournames0[i]);
					tawlp.setLabourHours(Utility.getFloat(labourHours0[i]));
					tawlp.setLabourPrice(Utility.getFloat(labourPrices0[i]));
					tawlp.setLabourAmount(Utility.getDouble(labourAmounts0[i]));
					tawlp
							.setBalanceAmount(Utility
									.getDouble(labourAmounts0[i]));
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawlp.setBalancePrice(Utility.getDouble(labourPrices0[i]));
					tawlp.setApplyPrice(Utility.getDouble(labourPrices0[i]));
					tawlp.setApplyQuantity(Utility.getDouble(labourHours0[i]));
					tawlp.setApplyAmount(Utility.getDouble(labourAmounts0[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					if("on".equals(itemIsFore)){
						tawlp.setIsFore(1); //授权
					}
					tawlp.setCreateBy(logonUser.getUserId());
					tawlp.setCreateDate(date);
					dao.insert(tawlp);
					// System.out.println("==========="+wrLabourCodes[i]+"================");
				}
			}
			tawap.setStdLabourAmount(stdHourAmount);
			tawap.setLabourHours(labourHoursMain);
			tawap.setReinforceHours(reinForceHoursMain);
			tawap.setReinLabourAmount(reinHourAmount);
			tawap.setLabourAmount(labourAmountMain);
			/*
			 * if (parts!=null) { tawap.setFailedPartNo(failedPartNo); }
			 */
			// 配件插入
			if (parts != null) {
				for (int i = 0; i < parts.length; i++) {
					/*
					 * // 第一个配件需要插入到索赔申请单表中 if (i == 0) {
					 * tawap.setFailedPartNo(partCodes[i]); //主损部件 }
					 */
					// 累计配件数量
					partsCount += Utility.getDouble(quantitys[i]);
					// 累计配件金额
					partsAmountMain += Utility.getDouble(amounts[i]);
					TtAsWrPartsitemPO tawp = new TtAsWrPartsitemPO();
					if ("on".equals(parts[i])) { // 是主损
						tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE);
						tawp.setWrLabourcode(appTime[i]);
					} else {
						tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE);
						tawp.setBMpCode(bMpCode[i]);
					}
					tawp.setId(claimId);
					tawp.setPartId(Utility.getLong(SequenceManager
							.getSequence("")));
					tawp.setPartCode(partCodes[i]);
					tawp.setPartName(partNames[i]);
					tawp.setDownPartCode(downPartCodes[i]);
					tawp.setDownPartName(downPartNames[i]);
					tawp.setQuantity(Utility.getFloat(quantitys[i]));
					tawp.setPrice(Utility.getDouble(prices[i]));
					tawp.setAmount(Utility.getDouble(amounts[i]));
					tawp.setBalanceAmount(Utility.getDouble(amounts[i]));
					tawp.setBalanceQuantity(Utility.getFloat(quantitys[i]));
					tawp.setProducerCode(supplierCodes[i]);
					tawp.setProducerName(supplierNames[i]);
					tawp.setDownProductCode(downSupplierCodes[i]);
					tawp.setDownProductName(downSupplierNames[i]);
					tawp.setPayType(Utility.getInt(partPayType[i]));
					tawp.setIsClaim(Long.valueOf(partClaim[i]));
					/**addUser:xiongchuan addDate:2010-12-14   **/
					tawp.setBalancePrice(Utility.getDouble(prices[i]));//结算价格
					tawp.setApplyAmount(Utility.getDouble(amounts[i]));//申请金额
					tawp.setApplyPrice(Utility.getDouble(prices[i]));//申请价格
					tawp.setApplyQuantity(Utility.getDouble(quantitys[i]));//申请数量
					/**endUser:xiongchuan endDate:2010-12-14   **/
					if ("on".equals(isGua[i])) {
						tawp.setIsGua(1);
					}else {
						tawp.setIsGua(0);
					}
					if("on".equals(partIsFore)){
						tawp.setIsFore(1); //授权
					}
					tawp.setCreateBy(logonUser.getUserId());
					tawp.setCreateDate(date);
					tawp.setRemark(remarks[i]);
					dao.insert(tawp);

					// System.out.println("==========="+wrLabourCodes[i]+"================");
				}
			}
			tawap.setPartsCount(partsCount);
			BigDecimal b = new BigDecimal(Double.toString(partsAmountMain));   
			BigDecimal one = new BigDecimal("1"); 
			tawap.setPartAmount(b.divide(one,2,BigDecimal.ROUND_HALF_UP).doubleValue()); 

			// 其他项目插入
			if (itemCodes != null) {
				for (int i = 0; i < itemCodes.length; i++) {
					// 累计其他项目总金额
					netItemAmount += Utility.getDouble(itemAmounts[i]);
					TtAsWrNetitemPO tawp = new TtAsWrNetitemPO();
					tawp.setId(claimId);
					tawp.setNetitemId(Utility.getLong(SequenceManager
							.getSequence("")));
					tawp.setItemCode(itemCodes[i]);
					tawp.setItemDesc(itemNames[i]);
					tawp.setAmount(Utility.getDouble(itemAmounts[i]));
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawp.setApplyAmount(Utility.getDouble(itemAmounts[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					tawp.setRemark(itemRemarks[i]);
					tawp.setBalanceAmount(Utility.getDouble(itemAmounts[i]));
					tawp.setPayType(Utility.getInt(otherPayType[i]));
					if("on".equals(otherIsFore)){
						tawp.setIsFore(1); //授权
					}
					tawp.setCreateBy(logonUser.getUserId());
					tawp.setCreateDate(date);
					dao.insert(tawp);
					// System.out.println("==========="+wrLabourCodes[i]+"================");
				}
			}
			repairTotal = labourAmountMain + partsAmountMain + netItemAmount
					+ campaignFeeDb + freeMPriceDb;
			tawap.setFreeMPrice(freeMPriceDb);
			tawap.setBalanceLabourAmount(labourAmountMain);
			tawap.setBalancePartAmount(partsAmountMain);
			/***addUser:xiongchuan addDate:2010-12-14  ***/
			tawap.setApplyLabourAmount(labourAmountMain);//经销商申请工时金额
			tawap.setApplyPartAmount(partsAmountMain);//经销商申请配件金额
			tawap.setApplyNetitemAmount(netItemAmount);//经销商其他项目费
			tawap.setApplyRepairTotal(repairTotal);//经销商申请总金额
			/***endUser:xiongchuan endDate:2010-12-14  ***/
			tawap.setNetitemAmount(netItemAmount);
			tawap.setBalanceNetitemAmount(netItemAmount);
			tawap.setRepairTotal(repairTotal);
			tawap.setBalanceAmount(repairTotal);
			tawap.setGrossCredit(repairTotal * 1);// 这里插入总金额 税额暂时设定为1
			tawap.setStatus(Constant.CLAIM_APPLY_ORD_TYPE_01);
			/**取得工时单价**/
			String parameterValue = dao.getLabourPrice(dealerId,modelCode,companyId.toString());
			tawap.setLabourPrice(Utility.getDouble(parameterValue));
			// 插入到索赔申请单表
			dao.insert(tawap);
			// 附件功能
			String ywzj = tawap.getId().toString();
			String[] fjids = request.getParamValues("fjids");
			FileUploadManager.fileUploadByBusiness(ywzj, fjids, logonUser);
			
				if (Utility.testString(itemIds1)) {
					String[] items1 = itemIds1.split(",");
					for (int i =0;i<items1.length;i++) {
						TtAsRoLabourPO tap = new TtAsRoLabourPO();
						tap.setId(Utility.getLong(items1[i]));
						TtAsRoLabourPO tapU = new TtAsRoLabourPO();
						tapU.setId(Utility.getLong(items1[i]));
						tapU.setIsSel("1");
						tapU.setIsClaim(1); //已经索赔
						dao.update(tap, tapU);
					}
				}
				if (Utility.testString(partIds1)) {
					String[] parts1 = partIds1.split(",");
					for (int i =0;i<parts1.length;i++) {
						TtAsRoRepairPartPO tap = new TtAsRoRepairPartPO();
						tap.setId(Utility.getLong(parts1[i]));
						TtAsRoRepairPartPO tapU = new TtAsRoRepairPartPO();
						tapU.setId(Utility.getLong(parts1[i]));
						tapU.setIsSel("1");
						tapU.setIsClaim(1); //已经索赔
						dao.update(tap, tapU);
					}
				}
				if (Utility.testString(otherIds1)){
					String[] others1 = otherIds1.split(",");
					for (int i =0;i<others1.length;i++) {
						TtAsRoAddItemPO tap = new TtAsRoAddItemPO();
						tap.setId(Utility.getLong(others1[i]));
						TtAsRoAddItemPO tapU = new TtAsRoAddItemPO();
						tapU.setId(Utility.getLong(others1[i]));
						tapU.setIsSel(1);
						tapU.setIsClaim(1); //已经索赔
						dao.update(tap, tapU);
					}
				}

			/*--------------------质量信息跟踪卡 start------------------*/
			String infoId = request.getParamValue("infoId");
			if (Utility.testString(infoId)) {
				TtAsWrInformationqualityPO tawip = new TtAsWrInformationqualityPO();
				tawip.setId(Utility.getLong(infoId));
				TtAsWrInformationqualityPO tawipU = new TtAsWrInformationqualityPO();
				tawipU.setId(Utility.getLong(infoId));
				tawipU.setClaimId(claimId);
				dao.update(tawip, tawipU);
			}
			/*--------------------质量信息跟踪卡 end------------------*/
			// 接口
			if (Utility.testString(roId)) {
				TtAsRoLabourPO tarlp = new TtAsRoLabourPO();
				tarlp.setRoId(Utility.getLong(roId));
				TtAsRoLabourPO tarlpUp = new TtAsRoLabourPO();
				tarlpUp.setRoId(Utility.getLong(roId));
				tarlpUp.setIsSel("");
			}
			//查询出firstPart
			String firstPart="";
			List<Map<String, Object>>  listFirst = dao.viewFirstPart(String.valueOf(claimId));
			if(listFirst.size()>0){
				for(int i=0;i<listFirst.size();i++){
					firstPart = listFirst.get(i).get("FIRST_PART").toString();
					List<Map<String, Object>>  listFirstCode = dao.viewPartCode(claimId, firstPart,listFirst.get(i).get("WR_LABOURCODE").toString());
					//到配件表根据firstPart 查处任意一个配件明细ID
					Long partId = Long.valueOf(listFirstCode.get(0).get("PART_ID").toString());
					//获取工时明细ID
					Long labourId = Long.valueOf(listFirst.get(i).get("LABOUR_ID").toString());
					//更新
					dao.updateFirstCode(labourId, partId);
				}
			}
			
			// 此时将车型ID与车系ID写入此索赔单
			StringBuffer sql = new StringBuffer("\n");
			sql.append("update tt_as_wr_application a\n");
			sql.append("   set a.series_id = (select v.series_id\n");  
			sql.append("                        from tm_vehicle v\n");  
			sql.append("                       where v.vin = a.vin),\n");  
			sql.append("       a.model_id  = (select v.model_id from tm_vehicle v where v.vin = a.vin)\n");  
			sql.append(" where a.id = ").append(claimId);
			dao.update(sql.toString(), null) ;
		
			claimBillForward();
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
		DBLockUtil.freeLock(roNo, DBLockUtil.BUSINESS_TYPE_13);
	}

	/**
	 * 
	 * @Title: applicationInsert
	 * @Description: TODO(修改索赔)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void applicationUpdate() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser);
		String dealerId = logonUser.getDealerId();
		StringBuffer con = new StringBuffer();
		Date date = new Date();
		try {

			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			Integer pageSize = 10;
			float labourHoursMain = 0f; // 基本工时数
			float reinForceHoursMain = 0f; // 附加工时数
			double stdHourAmount = 0; // 基本工时金额
			double reinHourAmount = 0; // 附加工时金额
			int partsCount = 0; // 总配件数
			double labourAmountMain = 0; // 总工时金额
			double partsAmountMain = 0; // 配件金额
			double netItemAmount = 0; // 其他项目金额
			double repairTotal = 0; // 索赔申请金额

			String roId = request.getParamValue("roId");

			String id = request.getParamValue("ID");
			String roNo = request.getParamValue("RO_NO"); // 工单号
			String lineNo = request.getParamValue("LINE_NO");// 行号
			lineNo = "1";
			String roStartdate = request.getParamValue("RO_STARTDATE");// 工单开始时间
			String roEnddate = request.getParamValue("RO_ENDDATE");// 工单结束时间
			String guaranteeDate = request.getParamValue("GUARANTEE_DATE");// 保修开始时间
			String serveAdvisor = request.getParamValue("SERVE_ADVISOR");// 接待员
			String vin = request.getParamValue("VIN");// VIN
			String remark = request.getParamValue("APP_REMARK");// 申请备注
			String claimType = request.getParamValue("CLAIM_TYPE"); // 索赔类型
			/*
			 * String damageType = request.getParamValue("DAMAGE_TYPE"); // 质损类型
			 * String damageArea = request.getParamValue("DAMAGE_AREA"); // 质损区域
			 * String damageDegree = request.getParamValue("DAMAGE_DEGREE"); //
			 * 质损程度 String troubleCode = request.getParamValue("TROUBLE_CODE"); //
			 * 故障代码
			 */String troubleDesc = request.getParamValue("TROUBLE_DESC");
			String troubleReason = request.getParamValue("TROUBLE_REASON");
			String repairMethod = request.getParamValue("REPAIR_METHOD");
			String inMileage = request.getParamValue("IN_MILEAGE");

			String campaignCode = request.getParamValue("CAMPAIGN_CODE"); // 服务活动代码
			String campaignFee = request.getParamValue("CAMPAIGN_FEE"); // 服务活动费用
			String isFixing = request.getParamValue("IS_FIX"); // 服务活动是否固定费用1为固定费用
			String IS_AUDIT = request.getParamValue("IS_AUDIT"); // 判断是否人工审核
			String freeMAmount = request.getParamValue("FREE_M_AMOUNT"); // 免费保养次数
			String freeMPrice = request.getParamValue("FREE_M_PRICE"); // 免费保养费用

			String yieldly = request.getParamValue("YIELDLY"); // 产地
			String licenseNo = request.getParamValue("LICENSE_NO"); // 车牌号
			String brandCode = request.getParamValue("BRAND_CODE0"); // 品牌
			String brandName = request.getParamValue("BRAND_NAME0");
			String modelCode = request.getParamValue("MODEL_CODE0"); // 车型
			String modelName = request.getParamValue("MODEL_NAME0");
			String seriesCode = request.getParamValue("SERIES_CODE0");// 车系
			String seriesName = request.getParamValue("SERIES_NAME0");
			String engineNo = request.getParamValue("ENGINE_NO");
			String gearboxNo = request.getParamValue("GEARBOX_NO0"); // 变速箱
			String rearaxleNo = request.getParamValue("REARAXLE_NO0"); // 后桥
			String transferNo = request.getParamValue("TRANSFER_NO0"); // 分动器
			
			// Long claimId = Utility.getLong(SequenceManager.getSequence(""));
			// // 产生一个索赔ID

			// 取得删除IDS
			String itemDel = request.getParamValue("ITEM_DEL");
			String[] labourIds = request.getParamValues("LABOUR_ID");
			String[] items = request.getParamValues("ITEM"); // 工时选择的CHECKBOX
			String[] wrLabourCodes = request.getParamValues("WR_LABOURCODE"); // 获取工时代码
			String[] wrLabournames = request.getParamValues("WR_LABOURNAME"); // 获取工时名称
			String[] labourHours = request.getParamValues("LABOUR_HOURS"); // 获取工时数
			String[] labourPrices = request.getParamValues("LABOUR_PRICE"); // 获取工时单价
			String[] labourAmounts = request.getParamValues("LABOUR_AMOUNT"); // 获取工时金额
			//String[] damageType = request.getParamValues("DAMAGE_TYPE"); // 质损类型
			//String[] damageArea = request.getParamValues("DAMAGE_AREA"); // 质损区域
			//String[] damageDegree = request.getParamValues("DAMAGE_DEGREE"); // 质损程度
			String[] troubleCode = request.getParamValues("TROUBLE_CODE"); // 故障代码
			//String[] damageTypeName = request.getParamValues("DAMAGE_TYPE_NAME"); // 质损类型
			//String[] damageAreaName = request.getParamValues("DAMAGE_AREA_NAME"); // 质损区域
			//String[] damageDegreeName = request.getParamValues("DAMAGE_DEGREE_NAME"); // 质损程度
			String[] troubleCodeName = request.getParamValues("TROUBLE_CODE_NAME"); // 故障代码
			String[] itemIsFore = request.getParamValues("ITEM_IS_FORE");//是否授权
			String[] itemPayType = request.getParamValues("PAY_TYPE_ITEM"); //付费类型
			String[] isClaim = request.getParamValues("IS_BAC"); //是否累加
			String[] labourHidden = request.getParamValues("LABOUR_HOURS_HI");
			

			/*****************zhumingwei 2011-02-12**************/
			String[] TROUBLE_TYPE_NAME = request.getParamValues("TROUBLE_TYPE_NAME");
			/*****************zhumingwei 2011-02-12**************/

			// 附加工时
			String[] bMlCode = request.getParamValues("B_ML_CODE");
			String[] labourIds0 = request.getParamValues("LABOUR_ID0"); // 附加工时ID
			String[] wrLabourCodes0 = request.getParamValues("WR_LABOURCODE0"); // 获取工时代码
			String[] wrLabournames0 = request.getParamValues("WR_LABOURNAME0"); // 获取工时名称
			String[] labourHours0 = request.getParamValues("LABOUR_HOURS0"); // 获取工时数
			String[] labourPrices0 = request.getParamValues("LABOUR_PRICE0"); // 获取工时单价
			String[] labourAmounts0 = request.getParamValues("LABOUR_AMOUNT0"); // 获取工时金额

			//
			String partDel = request.getParamValue("PART_DEL");
			String[] partIds = request.getParamValues("PART_ID"); // 取得PARTid
			String[] parts = request.getParamValues("PART");// 配件选择的CHECKBOX
			String[] partCodes = request.getParamValues("PART_CODE"); // 上件代码
			String[] partNames = request.getParamValues("PART_NAME"); // 上件名称
			String[] downPartCodes = request.getParamValues("DOWN_PART_CODE"); // 下件代码
			String[] downPartNames = request.getParamValues("DOWN_PART_NAME"); // 下件名称
			String[] quantitys = request.getParamValues("QUANTITY"); // 上件数量
			String[] prices = request.getParamValues("PRICE"); // 单价
			String[] amounts = request.getParamValues("AMOUNT"); // 数量
			String[] supplierCodes = request.getParamValues("PRODUCER_CODE");// 生产商代码
			String[] supplierNames = request.getParamValues("PRODUCER_NAME"); // 生产商名称
			String[] downSupplierCodes = request.getParamValues("PRODUCER_CODE1");// 生产商代码
			String[] downSupplierNames = request.getParamValues("PRODUCER_NAME1"); // 生产商名称
			String[] remarks = request.getParamValues("REMARK"); // 故障描述 yh 2010.11.29
			String[] appTime = request.getParamValues("appTime"); // 索赔工时
			String[] bMpCode = request.getParamValues("B_MP_CODE");// 所属主配件
			String[] partIsFore = request.getParamValues("PART_IS_FORE");//是否授权
			String[] partPayType = request.getParamValues("PAY_TYPE_PART");//付费类型
			String[] isGua = request.getParamValues("IS_GUA");//是否三包
			String[] partClaim = request.getParamValues("IS_BAC_PART"); //是否累加
			
			//
			String otherDel = request.getParamValue("OTHER_DEL");
			String[] itemIds = request.getParamValues("OTHER_ID");
			String[] itemCodes = request.getParamValues("ITEM_CODE"); // 其他项目代码
			String[] itemNames = request.getParamValues("ITEM_NAME"); // 其他项目名称
			String[] itemAmounts = request.getParamValues("ITEM_AMOUNT");// 其他项目金额
			String[] itemRemarks = request.getParamValues("ITEM_REMARK");// 备注
			String[] otherIsFore = request.getParamValues("OTHER_IS_FORE");//是否授权
			String[] otherPayType = request.getParamValues("PAY_TYPE_OTHER"); //付费类型
			String  claimZhiSun= request.getParamValue("CLAIM_ZHISHUN");//質損類型
			
			String itemIds1 = request.getParamValue("itemIds1");
			String partIds1 = request.getParamValue("partIds1");
			String otherIds1 = request.getParamValue("otherIds1");

			// 删除附件ID
			// String attIds = request.getParamValue("attIds");
			String[] attIds = request.getParamValues("uploadFjid");

			// 索赔单ID
			Long claimId = Utility.getLong(id);
			if (Utility.getInt(claimType) == Constant.CLA_TYPE_01) { // 一般索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_02) {// 免费保养
				wrLabourCodes = null;
				wrLabourCodes0 = null;
				parts = null;
				itemIds = null;
				itemCodes = null;
				TtAsWrPartsitemPO tawp = new TtAsWrPartsitemPO();
				tawp.setId(claimId);
				dao.delete(tawp);
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_03) {// 追加索赔
				wrLabourCodes = null;
				wrLabourCodes0 = null;
				parts = null;
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_04) {// 重复修理索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_05) {// 零件索赔更换
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_06) {// 服务活动
				if ("1".equals(isFixing)) { // 是固定费用
					wrLabourCodes = null;
					wrLabourCodes0 = null;
					parts = null;
					itemIds = null;
					itemCodes = null;
				} else {// 不是固定费用
					// campaignCode = null; //服务活动代码
					campaignFee = null; // 服务活动费用
					isFixing = null; // 服务活动是否固定费用1为固定费用
				}
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_07) {// PDI索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_08) {// 保外索赔
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
			} else if (Utility.getInt(claimType) == Constant.CLA_TYPE_09) {//外出维修
				campaignCode = null; // 服务活动代码
				campaignFee = null; // 服务活动费用
				isFixing = null; // 服务活动是否固定费用1为固定费用

				freeMAmount = null; // 免费保养次数
				freeMPrice = null; // 免费保养费用
				
			}
			Double campaignFeeDb = Utility.getDouble(campaignFee);
			Double freeMPriceDb = Utility.getDouble(freeMPrice);

			TtAsWrApplicationPO tawap0 = new TtAsWrApplicationPO();
			tawap0.setId(claimId);
			TtAsWrApplicationPO tawap = new TtAsWrApplicationPO();
			tawap.setId(claimId);
			// tawap.setClaimNo(SequenceManager.getSequence("CO"));
			tawap.setDealerId(Utility.getLong(dealerId));
			tawap.setRoNo(roNo);
			tawap.setLineNo(Utility.getInt(lineNo));
			tawap.setVin(vin);
			tawap.setRoStartdate(Utility.getDate(roStartdate, 1));
			tawap.setRoEnddate(Utility.getDate(roEnddate, 1));
			tawap.setGuaranteeDate(Utility.getDate(guaranteeDate, 1));
			tawap.setServeAdvisor(serveAdvisor);
			tawap.setClaimType(Utility.getInt(claimType));
			tawap.setLicenseNo(licenseNo);
			tawap.setBrandCode(brandCode);
			tawap.setBrandName(brandName);
			tawap.setModelCode(modelCode);
			tawap.setModelName(modelName);
			tawap.setSeriesCode(seriesCode);
			tawap.setSeriesName(seriesName);
			tawap.setEngineNo(engineNo);
			tawap.setGearboxNo(gearboxNo);
			tawap.setRearaxleNo(rearaxleNo);
			tawap.setTransferNo(transferNo);
			tawap.setYieldly(yieldly);
			/***add xiongchuan 2011-03-21  微車增加質損類型****/
			if(claimZhiSun!=null&&!claimZhiSun.equals("")){
				tawap.setDegradationType(Integer.valueOf(claimZhiSun));
			}
			/***add xiongchuan 2011-03-21  微車增加質損類型****/
			tawap.setIsAudit(Integer.valueOf(IS_AUDIT));
			/*
			 * tawap.setTroubleCode(troubleCode);
			 * tawap.setDamageType(damageType); tawap.setDamageArea(damageArea);
			 * tawap.setDamageDegree(damageDegree);
			 */

			tawap.setRemark(remark);
			tawap.setTroubleDesc(troubleDesc);
			tawap.setTroubleReason(troubleReason);
			tawap.setRepairMethod(repairMethod);
			tawap.setInMileage(Utility.getDouble(inMileage));
			tawap.setCampaignCode(campaignCode); // 服务活动代码
			tawap.setIsFixing(Utility.getInt(isFixing)); // 是否固定费用1为固定
			tawap.setCampaignFee(Utility.getDouble(campaignFee)); // 服务活动费用
			/**addUser:xiongchuan  addDate:2010-12-14   ***/
			tawap.setBalanceCampaignFee(Utility.getDouble(campaignFee));//经销商结算服务活动费用总金额
			tawap.setBalanceFreeMAmount(Utility.getDouble(freeMAmount));//经销商结算保养费用总金额
			tawap.setApplyCampaignFee(Utility.getDouble(campaignFee));//经销商申请服务活动费用总金额
			tawap.setApplyFreeMAmount(Utility.getDouble(freeMAmount));//经销商申请保养费用总金额
			/**endUser:xiongchuan  endDate:2010-12-14   ***/
			tawap.setFreeMAmount((int) Utility.getDouble(freeMAmount)); // 免费保养次数
			tawap.setFreeMPrice(freeMPriceDb); // 免费保养费用
			tawap.setUpdateBy(logonUser.getUserId());
			tawap.setUpdateDate(date);

			// 插入时需要对车辆信息表中的车牌号进行更新
			if(Utility.testString(vin)){
			TmVehiclePO tvp = new TmVehiclePO();
			tvp.setVin(vin);
			TmVehiclePO tvpUp = new TmVehiclePO();
			tvpUp.setLicenseNo(licenseNo);
			tvpUp.setUpdateBy(logonUser.getUserId());
			tvpUp.setUpdateDate(date);
			dao.update(tvp, tvpUp);
			}
			// 如果有删除的
			if (Utility.testString(itemDel)) {
				itemDel = itemDel.replaceFirst(",", "");
				String[] itemDels = itemDel.split(",");
				Set<String> itemSet = new HashSet<String>();
				// 避免重复ID
				for (int i = 0; i < itemDels.length; i++) {
					itemSet.add(itemDels[i]);
				}
				Iterator<String> it = itemSet.iterator();
				while (it.hasNext()) {
					TtAsWrLabouritemPO t = new TtAsWrLabouritemPO();
					t.setLabourId(Utility.getLong(it.next()));
					dao.delete(t);
				}

			}
			// 如果隐藏域中的labourId不是空（主工时）更新工时
			if (labourIds != null) {
				for (int i = 0; i < labourIds.length; i++) {
					// 主工时数量和金额
					labourHoursMain += Utility.getFloat(labourHours[i]);
					stdHourAmount += Utility.getDouble(labourAmounts[i]);
					// 累加附加工时数量和金额
					// reinForceHoursMain += Utility.getFloat(labourHours[i]);
					// reinHourAmount += Utility.getDouble(labourAmounts[i]);
					// 累加总工时金额
					labourAmountMain += Utility.getDouble(labourAmounts[i]);
					TtAsWrLabouritemPO tawlp0 = new TtAsWrLabouritemPO();
					tawlp0.setLabourId(Utility.getLong(labourIds[i]));
					TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
					// if (i == 0) {
					tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE);
					if (appTime!=null) {
						for (int z=0;z<appTime.length;z++) {
							if (wrLabourCodes[i].equals(appTime[z])) { //配件中是这个工时的
								tawlp.setFirstPart(partCodes[z]);
								break;
							}
						}
					}
					// } else {
					// tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE);
					// }
					tawlp.setLabourId(Utility.getLong(labourIds[i]));
					tawlp.setId(claimId);
					tawlp.setTroubleCode(troubleCode[i]);
					//tawlp.setDamageArea(damageArea[i]);
					//tawlp.setDamageDegree(damageDegree[i]);
					//tawlp.setDamageType(damageType[i]);
					tawlp.setTroubleCodeName(troubleCodeName[i]);
					//tawlp.setDamageAreaName(damageAreaName[i]);
					//tawlp.setDamageDegreeName(damageDegreeName[i]);
					//tawlp.setDamageTypeName(damageTypeName[i]);
					/*****zhumingwei 2011-02-12************/
					tawlp.setTroubleType(TROUBLE_TYPE_NAME[i]);
					/*****zhumingwei 2011-02-12************/
					tawlp.setWrLabourcode(wrLabourCodes[i]);
					tawlp.setWrLabourname(wrLabournames[i]);
					tawlp.setLabourHours(Utility.getFloat(labourHours[i]));
					tawlp.setLabourPrice(Utility.getFloat(labourPrices[i]));
					tawlp.setLabourAmount(Utility.getDouble(labourAmounts[i]));
					tawlp.setBalanceAmount(Utility.getDouble(labourAmounts[i]));
					tawlp.setPayType(Utility.getInt(itemPayType[i]));
					tawlp.setBalanceQuantity(Utility.getFloat(labourHours[i]));
					tawap.setLabourPrice(Utility.getDouble(labourPrices[i]));
					tawlp.setUpdateBy(logonUser.getUserId());
					tawlp.setIsClaim(Utility.getInt(isClaim[i]));
					tawlp.setLabourQuantityHidden(Utility.getDouble(labourHidden[i]));
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawlp.setBalancePrice(Utility.getDouble(labourPrices[i]));
					tawlp.setApplyPrice(Utility.getDouble(labourPrices[i]));
					tawlp.setApplyQuantity(Utility.getDouble(labourHours[i]));
					tawlp.setApplyAmount(Utility.getDouble(labourAmounts[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					tawlp.setUpdateDate(date);
					dao.update(tawlp0, tawlp);
				}
				// 工时插入
				// 如果工时代码多多于有ID的代码，证明新增了工时（主工时）
				if (wrLabourCodes.length > labourIds.length) {
					for (int i = labourIds.length; i < wrLabourCodes.length; i++) {
						// 累加附加工时数量和金额
						// reinForceHoursMain +=
						// Utility.getFloat(labourHours[i]);
						// reinHourAmount +=
						// Utility.getDouble(labourAmounts[i]);
						// 主工时数量和金额
						labourHoursMain += Utility.getFloat(labourHours[i]);
						stdHourAmount += Utility.getDouble(labourAmounts[i]);
						// 累加总工时金额
						labourAmountMain += Utility.getDouble(labourAmounts[i]);
						TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
						if (appTime!=null) {
							for (int z=0;z<appTime.length;z++) {
								if (wrLabourCodes[i].equals(appTime[z])) { //配件中是这个工时的
									tawlp.setFirstPart(partCodes[z]);
									break;
								}
							}
						}
						tawlp.setId(claimId);
						tawlp.setTroubleCode(troubleCode[i]);
						//tawlp.setDamageArea(damageArea[i]);
						//tawlp.setDamageDegree(damageDegree[i]);
						//tawlp.setDamageType(damageType[i]);
						tawlp.setTroubleCodeName(troubleCodeName[i]);
						//tawlp.setDamageAreaName(damageAreaName[i]);
						//tawlp.setDamageDegreeName(damageDegreeName[i]);
						//tawlp.setDamageTypeName(damageTypeName[i]);
						/*****zhumingwei 2011-02-12************/
						tawlp.setTroubleType(TROUBLE_TYPE_NAME[i]);
						/*****zhumingwei 2011-02-12************/
						tawlp.setLabourId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawlp.setWrLabourcode(wrLabourCodes[i]);
						tawlp.setWrLabourname(wrLabournames[i]);
						tawlp.setLabourHours(Utility.getFloat(labourHours[i]));
						tawlp.setLabourPrice(Utility.getFloat(labourPrices[i]));
						tawlp.setLabourAmount(Utility
								.getDouble(labourAmounts[i]));
						tawlp.setBalanceAmount(Utility
								.getDouble(labourAmounts[i]));
						tawlp.setPayType(Utility.getInt(itemPayType[i]));
						if("on".equals(itemIsFore)){
							tawlp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawlp.setBalancePrice(Utility.getDouble(labourPrices[i]));
						tawlp.setApplyPrice(Utility.getDouble(labourPrices[i]));
						tawlp.setApplyQuantity(Utility.getDouble(labourHours[i]));
						tawlp.setApplyAmount(Utility.getDouble(labourAmounts[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						tawap.setLabourPrice(Utility.getDouble(labourPrices[i]));
						tawlp.setBalanceQuantity(Utility.getFloat(labourHours[i]));
						tawlp.setCreateBy(logonUser.getUserId());
						tawlp.setCreateDate(date);
						dao.insert(tawlp);
					}
				}
				// labourIds如果为空（全部为新增）
			} else {
				if (wrLabourCodes != null) {
					for (int i = 0; i < wrLabourCodes.length; i++) {
						/* if (i == 0) { */
						// 主工时数量和金额
						labourHoursMain = Utility.getFloat(labourHours[i]);
						stdHourAmount = Utility.getDouble(labourAmounts[i]);
						/*
						 * } else { // 累加附加工时数量和金额 reinForceHoursMain += Utility
						 * .getFloat(labourHours[i]); reinHourAmount += Utility
						 * .getDouble(labourAmounts[i]); }
						 */
						// 累加总工时金额
						labourAmountMain += Utility.getDouble(labourAmounts[i]);
						TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
						/* if (i == 0) { */
						tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE);
						/*
						 * } else {
						 * tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE); }
						 */
						tawlp.setId(claimId);
						if (appTime!=null) {
							for (int z=0;z<appTime.length;z++) {
								if (wrLabourCodes[i].equals(appTime[z])) { //配件中是这个工时的
									tawlp.setFirstPart(partCodes[z]);
									break;
								}
							}
						}
						tawlp.setTroubleCode(troubleCode[i]);
						//tawlp.setDamageArea(damageArea[i]);
						//tawlp.setDamageDegree(damageDegree[i]);
						//tawlp.setDamageType(damageType[i]);
						tawlp.setTroubleCodeName(troubleCodeName[i]);
						//tawlp.setDamageAreaName(damageAreaName[i]);
						//tawlp.setDamageDegreeName(damageDegreeName[i]);
						//tawlp.setDamageTypeName(damageTypeName[i]);
						/*****zhumingwei 2011-02-12************/
						tawlp.setTroubleType(TROUBLE_TYPE_NAME[i]);
						/*****zhumingwei 2011-02-12************/
						tawlp.setLabourId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawlp.setWrLabourcode(wrLabourCodes[i]);
						tawlp.setWrLabourname(wrLabournames[i]);
						tawlp.setLabourHours(Utility.getFloat(labourHours[i]));
						tawlp.setLabourPrice(Utility.getFloat(labourPrices[i]));
						tawlp.setLabourAmount(Utility.getDouble(labourAmounts[i]));
						tawlp.setBalanceAmount(Utility.getDouble(labourAmounts[i]));
						tawlp.setPayType(Utility.getInt(itemPayType[i]));
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawlp.setBalancePrice(Utility.getDouble(labourPrices[i]));
						tawlp.setApplyPrice(Utility.getDouble(labourPrices[i]));
						tawlp.setApplyQuantity(Utility.getDouble(labourHours[i]));
						tawlp.setApplyAmount(Utility.getDouble(labourAmounts[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						if("on".equals(itemIsFore)){
							tawlp.setIsFore(1); //授权
						}
						tawap.setLabourPrice(Utility.getDouble(labourPrices[i]));
						tawlp.setBalanceQuantity(Utility.getFloat(labourHours[i]));
						tawlp.setCreateBy(logonUser.getUserId());
						tawlp.setCreateDate(date);
						dao.insert(tawlp);
					}
				}
			}
			// 如果隐藏域中的labourId不是空 (附加工时)
			if (labourIds0 != null) {
				for (int i = 0; i < labourIds0.length; i++) {
					/*
					 * // 主工时数量和金额 labourHoursMain +=
					 * Utility.getFloat(labourHours[i]); stdHourAmount +=
					 * Utility.getDouble(labourAmounts[i]);
					 */
					// 累加附加工时数量和金额
					reinForceHoursMain += Utility.getFloat(labourHours0[i]);
					reinHourAmount += Utility.getDouble(labourAmounts0[i]);
					// 累加总工时金额
					labourAmountMain += Utility.getDouble(labourAmounts0[i]);
					TtAsWrLabouritemPO tawlp0 = new TtAsWrLabouritemPO();
					tawlp0.setLabourId(Utility.getLong(labourIds0[i]));
					TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
					// if (i == 0) {
					// tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE);
					// } else {
					tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE);
					// }
					tawlp.setLabourId(Utility.getLong(labourIds0[i]));
					tawlp.setId(claimId);
					tawlp.setBMlCode(bMlCode[i]);
					tawlp.setWrLabourcode(wrLabourCodes0[i]);
					tawlp.setWrLabourname(wrLabournames0[i]);
					tawlp.setLabourHours(Utility.getFloat(labourHours0[i]));
					tawlp.setLabourPrice(Utility.getFloat(labourPrices0[i]));
					tawlp.setLabourAmount(Utility.getDouble(labourAmounts0[i]));
					tawlp.setBalanceAmount(Utility.getDouble(labourAmounts0[i]));
					if("on".equals(itemIsFore)){
						tawlp.setIsFore(1); //授权
					}
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawlp.setBalancePrice(Utility.getDouble(labourPrices0[i]));
					tawlp.setApplyPrice(Utility.getDouble(labourPrices0[i]));
					tawlp.setApplyQuantity(Utility.getDouble(labourHours0[i]));
					tawlp.setApplyAmount(Utility.getDouble(labourAmounts0[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					tawlp.setUpdateBy(logonUser.getUserId());
					tawlp.setUpdateDate(date);
					dao.update(tawlp0, tawlp);
				}
				// 工时插入
				// 如果工时代码多多于有ID的代码，证明新增了工时
				if (wrLabourCodes0.length > labourIds0.length) {
					for (int i = labourIds0.length; i < wrLabourCodes0.length; i++) {
						// 累加附加工时数量和金额
						reinForceHoursMain += Utility.getFloat(labourHours0[i]);
						reinHourAmount += Utility.getDouble(labourAmounts0[i]);
						// 累加总工时金额
						labourAmountMain += Utility
								.getDouble(labourAmounts0[i]);
						TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
						tawlp.setId(claimId);
						tawlp.setBMlCode(bMlCode[i]);
						tawlp.setLabourId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawlp.setWrLabourcode(wrLabourCodes0[i]);
						tawlp.setWrLabourname(wrLabournames0[i]);
						tawlp.setLabourHours(Utility.getFloat(labourHours0[i]));
						tawlp
								.setLabourPrice(Utility
										.getFloat(labourPrices0[i]));
						tawlp.setLabourAmount(Utility
								.getDouble(labourAmounts0[i]));
						tawlp.setBalanceAmount(Utility
								.getDouble(labourAmounts0[i]));
						if("on".equals(itemIsFore)){
							tawlp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawlp.setBalancePrice(Utility.getDouble(labourPrices0[i]));
						tawlp.setApplyPrice(Utility.getDouble(labourPrices0[i]));
						tawlp.setApplyQuantity(Utility.getDouble(labourHours0[i]));
						tawlp.setApplyAmount(Utility.getDouble(labourAmounts0[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						tawlp.setCreateBy(logonUser.getUserId());
						tawlp.setCreateDate(date);
						dao.insert(tawlp);
					}
				}
				// labourIds如果为空
			} else {
				if (wrLabourCodes0 != null) {
					for (int i = 0; i < wrLabourCodes0.length; i++) {
						/*
						 * if (i == 0) { // 主工时数量和金额 labourHoursMain =
						 * Utility.getFloat(labourHours0[i]); stdHourAmount =
						 * Utility.getDouble(labourAmounts0[i]); } else {
						 */
						// 累加附加工时数量和金额
						reinForceHoursMain += Utility.getFloat(labourHours0[i]);
						reinHourAmount += Utility.getDouble(labourAmounts0[i]);
						// }
						// 累加总工时金额
						labourAmountMain += Utility
								.getDouble(labourAmounts0[i]);
						TtAsWrLabouritemPO tawlp = new TtAsWrLabouritemPO();
						/*
						 * if (i == 0) {
						 * tawlp.setIsMainlabour(Constant.IS_MAIN_TROUBLE); }
						 * else {
						 */
						tawlp.setIsMainlabour(Constant.IS_NOT_MAIN_TROUBLE);
						// }
						tawlp.setId(claimId);
						tawlp.setBMlCode(bMlCode[i]);
						tawlp.setLabourId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawlp.setWrLabourcode(wrLabourCodes0[i]);
						tawlp.setWrLabourname(wrLabournames0[i]);
						tawlp.setLabourHours(Utility.getFloat(labourHours0[i]));
						tawlp
								.setLabourPrice(Utility
										.getFloat(labourPrices0[i]));
						tawlp.setLabourAmount(Utility
								.getDouble(labourAmounts0[i]));
						tawlp.setBalanceAmount(Utility
								.getDouble(labourAmounts0[i]));
						if("on".equals(itemIsFore)){
							tawlp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawlp.setBalancePrice(Utility.getDouble(labourPrices0[i]));
						tawlp.setApplyPrice(Utility.getDouble(labourPrices0[i]));
						tawlp.setApplyQuantity(Utility.getDouble(labourHours0[i]));
						tawlp.setApplyAmount(Utility.getDouble(labourAmounts0[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						tawlp.setCreateBy(logonUser.getUserId());
						tawlp.setCreateDate(date);
						dao.insert(tawlp);
					}
				}
			}
			tawap.setStdLabourAmount(stdHourAmount);
			tawap.setLabourHours(labourHoursMain);
			tawap.setReinforceHours(reinForceHoursMain);
			tawap.setReinLabourAmount(reinHourAmount);
			tawap.setLabourAmount(labourAmountMain);

			/*
			 * if (parts!=null) { tawap.setFailedPartNo(failedPartNo); }
			 */
			// 删除配件
			if (Utility.testString(partDel)) {
				partDel = partDel.replaceFirst(",", "");
				String[] partDels = partDel.split(",");
				Set<String> partSet = new HashSet<String>();
				// 避免重复ID
				for (int i = 0; i < partDels.length; i++) {
					partSet.add(partDels[i]);
				}
				Iterator<String> it = partSet.iterator();
				while (it.hasNext()) {
					TtAsWrPartsitemPO t = new TtAsWrPartsitemPO();
					t.setPartId(Utility.getLong(it.next()));
					dao.delete(t);
				}

			}
			// 配件插入(存在配件ID的更新)
			if (partIds != null) {
				for (int i = 0; i < partIds.length; i++) {
					/*
					 * // 第一个配件需要插入到索赔申请单表中 if (i == 0) {
					 * tawap.setFailedPartNo(partCodes[i]); }
					 */
					// 累计配件数量
					partsCount += Utility.getDouble(quantitys[i]);
					// 累计配件金额
					partsAmountMain += Utility.getDouble(amounts[i]);
					TtAsWrPartsitemPO tawp0 = new TtAsWrPartsitemPO();
					tawp0.setPartId(Utility.getLong(partIds[i]));
					TtAsWrPartsitemPO tawp = new TtAsWrPartsitemPO();
					/*
					 * if (i == 0) {
					 * tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE); } else {
					 * tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE); }
					 */
					if ("on".equals(parts[i])) { // 是主损
						tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE);
						tawp.setWrLabourcode(appTime[i]);
					} else {
						tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE);
						tawp.setBMpCode(bMpCode[i]);
					}
					tawp.setPartId(Utility.getLong(partIds[i]));
					tawp.setId(claimId);
					tawp.setPartCode(partCodes[i]);
					tawp.setPartName(partNames[i]);
					tawp.setDownPartCode(downPartCodes[i]);
					tawp.setDownPartName(downPartNames[i]);
					tawp.setQuantity(Utility.getFloat(quantitys[i]));
					tawp.setPrice(Utility.getDouble(prices[i]));
					tawp.setAmount(Utility.getDouble(amounts[i]));
					tawp.setBalanceAmount(Utility.getDouble(amounts[i]));
					tawp.setProducerCode(supplierCodes[i]);
					tawp.setProducerName(supplierNames[i]);
					tawp.setDownProductCode(downSupplierCodes[i]);
					tawp.setDownProductName(downSupplierNames[i]);
					tawp.setPayType(Utility.getInt(partPayType[i]));
					tawp.setIsClaim(Long.valueOf(partClaim[i]));//是否累加费用
					if("on".equals(partIsFore)){
						tawp.setIsFore(1); //授权
					}
					/**addUser:xiongchuan addDate:2010-12-14   **/
					tawp.setBalancePrice(Utility.getDouble(prices[i]));//结算价格
					tawp.setApplyAmount(Utility.getDouble(amounts[i]));//申请金额
					tawp.setApplyPrice(Utility.getDouble(prices[i]));//申请价格
					tawp.setApplyQuantity(Utility.getDouble(quantitys[i]));//申请数量
					/**endUser:xiongchuan endDate:2010-12-14   **/
					tawp.setBalanceQuantity(Utility.getFloat(quantitys[i]));
					tawp.setUpdateBy(logonUser.getUserId());
					tawp.setUpdateDate(date);
					tawp.setRemark(CommonUtils.checkNull(remarks[i]));
					dao.update(tawp0, tawp);
				}
				// 如果partCodes的长度大于partIds则说明新增了配件
				if (partCodes.length > partIds.length) {
					for (int i = partIds.length; i < partCodes.length; i++) {
						/*
						 * // 第一个配件需要插入到索赔申请单表中 if (i == 0) {
						 * tawap.setFailedPartNo(partCodes[i]); }
						 */
						// 累计配件数量
						partsCount += Utility.getDouble(amounts[i]);
						// 累计配件金额
						partsAmountMain += Utility.getDouble(amounts[i]);

						TtAsWrPartsitemPO tawp = new TtAsWrPartsitemPO();
						if ("on".equals(parts[i])) { // 是主损
							tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE);
							tawp.setWrLabourcode(appTime[i]);
						} else {
							tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE);
							tawp.setBMpCode(bMpCode[i]);
						}
						tawp.setId(claimId);
						tawp.setPartId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawp.setPartCode(partCodes[i]);
						tawp.setPartName(partNames[i]);
						tawp.setDownPartCode(downPartCodes[i]);
						tawp.setDownPartName(downPartNames[i]);
						tawp.setQuantity(Utility.getFloat(quantitys[i]));
						tawp.setPrice(Utility.getDouble(prices[i]));
						tawp.setAmount(Utility.getDouble(amounts[i]));
						tawp.setBalanceAmount(Utility.getDouble(amounts[i]));
						tawp.setProducerCode(supplierCodes[i]);
						tawp.setProducerName(supplierNames[i]);
						tawp.setDownProductCode(downSupplierCodes[i]);
						tawp.setDownProductName(downSupplierNames[i]);
						tawp.setPayType(Utility.getInt(partPayType[i]));
						if("on".equals(partIsFore)){
							tawp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14   **/
						tawp.setBalancePrice(Utility.getDouble(prices[i]));//结算价格
						tawp.setApplyAmount(Utility.getDouble(amounts[i]));//申请金额
						tawp.setApplyPrice(Utility.getDouble(prices[i]));//申请价格
						tawp.setApplyQuantity(Utility.getDouble(quantitys[i]));//申请数量
						/**endUser:xiongchuan endDate:2010-12-14   **/
						tawp.setBalanceQuantity(Utility.getFloat(quantitys[i]));
						tawp.setCreateBy(logonUser.getUserId());
						tawp.setCreateDate(date);
						tawp.setRemark(remarks[i]);
						dao.insert(tawp);

						// System.out.println("==========="+wrLabourCodes[i]+"================");
					}
				}
				// 如果没有partIds则全部新增操作
			} else {
				if (partCodes != null) {
					for (int i = 0; i < partCodes.length; i++) {
						/*
						 * // 第一个配件需要插入到索赔申请单表中 if (i == 0) {
						 * tawap.setFailedPartNo(partCodes[i]); }
						 */
						// 累计配件数量
						partsCount += Utility.getDouble(amounts[i]);
						// 累计配件金额
						partsAmountMain += Utility.getDouble(amounts[i]);
						TtAsWrPartsitemPO tawp = new TtAsWrPartsitemPO();
						/*
						 * if (i == 0) {
						 * tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE); } else {
						 * tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE); }
						 */
						if ("on".equals(parts[i])) { // 是主损
							tawp.setIsMainpart(Constant.IS_MAIN_TROUBLE);
							tawp.setWrLabourcode(appTime[i]);
						} else {
							tawp.setIsMainpart(Constant.IS_NOT_MAIN_TROUBLE);
							tawp.setBMpCode(bMpCode[i]);
						}
						tawp.setId(claimId);
						tawp.setPartId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawp.setPartCode(partCodes[i]);
						tawp.setPartName(partNames[i]);
						tawp.setDownPartCode(downPartCodes[i]);
						tawp.setDownPartName(downPartNames[i]);
						tawp.setQuantity(Utility.getFloat(quantitys[i]));
						tawp.setPrice(Utility.getDouble(prices[i]));
						tawp.setAmount(Utility.getDouble(amounts[i]));
						tawp.setBalanceAmount(Utility.getDouble(amounts[i]));
						tawp.setProducerCode(supplierCodes[i]);
						tawp.setProducerName(supplierNames[i]);
						tawp.setDownProductCode(downSupplierCodes[i]);
						tawp.setDownProductName(downSupplierNames[i]);
						tawp.setPayType(Utility.getInt(partPayType[i]));
						if("on".equals(partIsFore)){
							tawp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14   **/
						tawp.setBalancePrice(Utility.getDouble(prices[i]));//结算价格
						tawp.setApplyAmount(Utility.getDouble(amounts[i]));//申请金额
						tawp.setApplyPrice(Utility.getDouble(prices[i]));//申请价格
						tawp.setApplyQuantity(Utility.getDouble(quantitys[i]));//申请数量
						/**endUser:xiongchuan endDate:2010-12-14   **/
						tawp.setBalanceQuantity(Utility.getFloat(quantitys[i]));
						tawp.setCreateBy(logonUser.getUserId());
						tawp.setCreateDate(date);
						tawp.setRemark(remarks[i]);
						dao.insert(tawp);

						// System.out.println("==========="+wrLabourCodes[i]+"================");
					}
				}
			}
			tawap.setPartsCount(partsCount);
			tawap.setPartAmount(partsAmountMain);

			// 删除其他项目
			if (Utility.testString(otherDel)) {
				otherDel = otherDel.replaceFirst(",", "");
				String[] otherDels = otherDel.split(",");
				Set<String> otherSet = new HashSet<String>();
				// 避免重复ID
				for (int i = 0; i < otherDels.length; i++) {
					otherSet.add(otherDels[i]);
				}
				Iterator<String> it = otherSet.iterator();
				while (it.hasNext()) {
					TtAsWrNetitemPO t = new TtAsWrNetitemPO();
					t.setNetitemId(Utility.getLong(it.next()));
					dao.delete(t);
				}

			}
			// 其他项目插入
			if (itemIds != null) {
				for (int i = 0; i < itemIds.length; i++) {
					// 累计其他项目总金额
					netItemAmount += Utility.getDouble(itemAmounts[i]);
					TtAsWrNetitemPO tawp0 = new TtAsWrNetitemPO();
					tawp0.setNetitemId(Utility.getLong(itemIds[i]));
					TtAsWrNetitemPO tawp = new TtAsWrNetitemPO();
					tawp.setId(claimId);
					tawp.setNetitemId(Utility.getLong(itemIds[i]));
					tawp.setItemCode(itemCodes[i]);
					tawp.setItemDesc(itemNames[i]);
					tawp.setAmount(Utility.getDouble(itemAmounts[i]));
					tawp.setBalanceAmount(Utility.getDouble(itemAmounts[i]));
					if("on".equals(otherIsFore)){
						tawp.setIsFore(1); //授权
					}
					/**addUser:xiongchuan addDate:2010-12-14 **/
					tawp.setApplyAmount(Utility.getDouble(itemAmounts[i]));
					/**endUser:xiongchuan endDate:2010-12-14 **/
					tawp.setRemark(itemRemarks[i]);
					tawp.setUpdateBy(logonUser.getUserId());
					tawp.setUpdateDate(date);
					dao.update(tawp0, tawp);
				}
				if (itemCodes.length > itemIds.length) {
					for (int i = itemIds.length; i < itemCodes.length; i++) {
						// 累计其他项目总金额
						netItemAmount += Utility.getDouble(itemAmounts[i]);
						TtAsWrNetitemPO tawp = new TtAsWrNetitemPO();
						tawp.setId(claimId);
						tawp.setNetitemId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawp.setItemCode(itemCodes[i]);
						tawp.setItemDesc(itemNames[i]);
						tawp.setAmount(Utility.getDouble(itemAmounts[i]));
						tawp
								.setBalanceAmount(Utility
										.getDouble(itemAmounts[i]));
						tawp.setPayType(Utility.getInt(otherPayType[i]));
						if("on".equals(otherIsFore)){
							tawp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawp.setApplyAmount(Utility.getDouble(itemAmounts[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						tawp.setRemark(itemRemarks[i]);
						tawp.setCreateBy(logonUser.getUserId());
						tawp.setCreateDate(date);
						dao.insert(tawp);
					}
				}
				// 如果为空，则全部为新增
			} else {
				if (itemCodes != null) {
					for (int i = 0; i < itemCodes.length; i++) {
						// 累计其他项目总金额
						netItemAmount += Utility.getDouble(itemAmounts[i]);
						TtAsWrNetitemPO tawp = new TtAsWrNetitemPO();
						tawp.setId(claimId);
						tawp.setNetitemId(Utility.getLong(SequenceManager
								.getSequence("")));
						tawp.setItemCode(itemCodes[i]);
						tawp.setItemDesc(itemNames[i]);
						tawp.setAmount(Utility.getDouble(itemAmounts[i]));
						tawp.setBalanceAmount(Utility.getDouble(itemAmounts[i]));
						tawp.setPayType(Utility.getInt(otherPayType[i]));
						if("on".equals(otherIsFore)){
							tawp.setIsFore(1); //授权
						}
						/**addUser:xiongchuan addDate:2010-12-14 **/
						tawp.setApplyAmount(Utility.getDouble(itemAmounts[i]));
						/**endUser:xiongchuan endDate:2010-12-14 **/
						tawp.setRemark(itemRemarks[i]);
						tawp.setCreateBy(logonUser.getUserId());
						tawp.setCreateDate(date);
						dao.insert(tawp);
					}
				}
			}
			repairTotal = labourAmountMain + partsAmountMain + netItemAmount
					+ campaignFeeDb + freeMPriceDb;
			tawap.setBalanceLabourAmount(labourAmountMain);
			tawap.setBalancePartAmount(partsAmountMain);
			/**addUse:xiongchuan addDate:2010-12-14    **/
			tawap.setApplyLabourAmount(labourAmountMain);//经销商申请工时金额
			tawap.setApplyPartAmount(partsAmountMain);//经销商申请配件金额
			tawap.setApplyNetitemAmount(netItemAmount);//经销商其他项目费
			tawap.setApplyRepairTotal(repairTotal);//经销商申请总金额
			/**endUse:xiongchuan endDate:2010-12-14   **/
			tawap.setBalanceNetitemAmount(netItemAmount);
			tawap.setNetitemAmount(netItemAmount);
			tawap.setRepairTotal(repairTotal);
			tawap.setBalanceAmount(repairTotal);
			tawap.setGrossCredit(repairTotal * 1);// 这里插入总金额 税额暂时设定为1
			tawap.setStatus(Constant.CLAIM_APPLY_ORD_TYPE_01);
			/**取得工时单价**/
			String parameterValue = dao.getLabourPrice(dealerId,modelCode,companyId.toString());
			tawap.setLabourPrice(Utility.getDouble(parameterValue));
			// 插入到索赔申请单表
			dao.update(tawap0, tawap);

			// 附件功能
			// String ywzj = tawap.getId().toString();
			// String fjids = request.getParamValue("fjids");
			// FileUploadManager.delAllFilesUploadByBusiness(ywzj, attIds);
			// FileUploadManager.fileUploadByBusiness(ywzj, fjids, logonUser);
			String ywzj = tawap.getId().toString();
			String[] fjids = request.getParamValues("fjid");
			FileUploadManager.delAllFilesUploadByBusiness(ywzj, fjids);
			FileUploadManager.fileUploadByBusiness(ywzj, fjids, logonUser);
			
			
			if (Utility.testString(itemIds1)) {
				String[] items1 = itemIds1.split(",");
				for (int i =0;i<items1.length;i++) {
					TtAsRoLabourPO tap = new TtAsRoLabourPO();
					tap.setId(Utility.getLong(items1[i]));
					TtAsRoLabourPO tapU = new TtAsRoLabourPO();
					tapU.setId(Utility.getLong(items1[i]));
					tapU.setIsSel("1");
					tapU.setIsClaim(1); //已经索赔
					dao.update(tap, tapU);
				}
			}
			if (Utility.testString(partIds1)) {
				String[] parts1 = partIds1.split(",");
				for (int i =0;i<parts1.length;i++) {
					TtAsRoRepairPartPO tap = new TtAsRoRepairPartPO();
					tap.setId(Utility.getLong(parts1[i]));
					TtAsRoRepairPartPO tapU = new TtAsRoRepairPartPO();
					tapU.setId(Utility.getLong(parts1[i]));
					tapU.setIsSel("1");
					tapU.setIsClaim(1); //已经索赔
					dao.update(tap, tapU);
				}
			}
			if (Utility.testString(otherIds1)){
				String[] others1 = otherIds1.split(",");
				for (int i =0;i<others1.length;i++) {
					TtAsRoAddItemPO tap = new TtAsRoAddItemPO();
					tap.setId(Utility.getLong(others1[i]));
					TtAsRoAddItemPO tapU = new TtAsRoAddItemPO();
					tapU.setId(Utility.getLong(others1[i]));
					tapU.setIsSel(1);
					tapU.setIsClaim(1); //已经索赔
					dao.update(tap, tapU);
				}
			}

			
			/*--------------------质量信息跟踪卡 start------------------*/
			String infoId = request.getParamValue("infoId");
			if (Utility.testString(infoId)) {
				TtAsWrInformationqualityPO tawip = new TtAsWrInformationqualityPO();
				tawip.setId(Utility.getLong(infoId));
				TtAsWrInformationqualityPO tawipU = new TtAsWrInformationqualityPO();
				tawipU.setId(Utility.getLong(infoId));
				tawipU.setClaimId(claimId);
				dao.update(tawip, tawipU);
			}
			/*--------------------质量信息跟踪卡 end------------------*/

			// 接口
			if (Utility.testString(roId)) {
				TtAsRoLabourPO tarlp = new TtAsRoLabourPO();
				tarlp.setRoId(Utility.getLong(roId));
				TtAsRoLabourPO tarlpUp = new TtAsRoLabourPO();
				tarlpUp.setRoId(Utility.getLong(roId));
				tarlpUp.setIsSel("");
			}
			//查询出firstPart
			String firstPart="";
			List<Map<String, Object>>  listFirst = dao.viewFirstPart(String.valueOf(claimId));
			if(listFirst.size()>0){
				for(int i=0;i<listFirst.size();i++){
					firstPart = listFirst.get(i).get("FIRST_PART").toString();
					List<Map<String, Object>>  listFirstCode = dao.viewPartCode(claimId, firstPart,listFirst.get(i).get("WR_LABOURCODE").toString());
					//到配件表根据firstPart 查处任意一个配件明细ID
					Long partId = Long.valueOf(listFirstCode.get(0).get("PART_ID").toString());
					//获取工时明细ID
					Long labourId = Long.valueOf(listFirst.get(i).get("LABOUR_ID").toString());
					//更新
					dao.updateFirstCode(labourId, partId);
				}
			}
			claimBillForward();
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: getOutDetailByRoNo 
	* @Description: TODO(根据RO_NO取得外出维修详细) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void getOutDetailByRoNo(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			String roNo = request.getParamValue("roNo");
			TtAsWrOutrepairPO tawo = new TtAsWrOutrepairPO();
			if (Utility.testString(roNo)) {
				tawo.setRoNo(roNo);
				List<TtAsWrOutrepairPO> ls = dao.select(tawo);
				if (ls!=null) {
					if (ls.size()>0) {
						tawo = ls.get(0);
					}
				}
			}
			act.setOutData("outBean", tawo);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: verifyDupRo
	 * @Description: TODO(验证索赔单中的工单号和行号，一个工单号加一个行号可以唯一标识一个索赔单)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void verifyDupRo() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			RequestWrapper request = act.getRequest();
			String roNo = request.getParamValue("roNo"); // 工单号
			String lineNo = request.getParamValue("lineNo");// 行号
			Boolean dup = false; // 默认没有重复
			TtAsWrApplicationPO tawap = new TtAsWrApplicationPO();
			if (Utility.testString(roNo)) {
				tawap.setRoNo(roNo);
				if (Utility.testString(lineNo)) {
					tawap.setLineNo(Utility.getInt(lineNo));
				}
				List<TtAsWrApplicationPO> ls = dao.select(tawap);
				if (ls != null) {
					if (ls.size() > 0) {
						dup = true; // 工单有重复
					}
				}
			}
			/*
			 * if (Utility.testString(lineNo)) {
			 * tawap.setLineNo(Utility.getInt(lineNo)); List<TtAsWrApplicationPO>
			 * ls1 = dao.select(tawap); if (ls1 != null) { if (ls1.size() > 0) {
			 * liDu = true;// 行号有重复 } } }
			 */
			act.setOutData("dup", dup);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: verifyVINExist 
	* @Description: TODO(判断系统中是否存在vin) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void verifyVINExist() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			RequestWrapper request = act.getRequest();
			String vin = request.getParamValue("VIN"); // VIN
			Boolean exist = false; // 默认没有重复
			TmVehiclePO tawap = new TmVehiclePO();
			if (Utility.testString(vin)) {
				tawap.setVin(vin);
				
				List<TmVehiclePO> ls = dao.select(tawap);
				if (ls != null) {
					if (ls.size() > 0) {
						exist = true; // 存在
					}
				}
			}
			/*
			 * if (Utility.testString(lineNo)) {
			 * tawap.setLineNo(Utility.getInt(lineNo)); List<TtAsWrApplicationPO>
			 * ls1 = dao.select(tawap); if (ls1 != null) { if (ls1.size() > 0) {
			 * liDu = true;// 行号有重复 } } }
			 */
			act.setOutData("dup", exist);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemQuery
	 * @Description: TODO(工单中工时，配件，其他项目查询)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void roItemQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID

		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId");// 活动ID
			String modelId = request.getParamValue("modelId");
			
			Map<String, String> map = new HashMap<String, String>();
			map.put("roId", roId);
			PageResult<TtAsRepairOrderExtPO> ps = dao.queryRepairOrder(map,
					Constant.PAGE_SIZE, 1);
			List<TtAsRepairOrderExtPO> ls = ps.getRecords();
			TtAsRepairOrderExtPO tarp = new TtAsRepairOrderExtPO();
			if (ls != null) {
				if (ls.size() > 0) {
					tarp = ls.get(0);
				}
			}
			TtAsRepairOrderPO bean = new TtAsRepairOrderPO();
			bean.setId(Utility.getLong(roId));
			List<TtAsRepairOrderPO> ls0 = dao.select(bean);
			bean = ls0.get(0);
			TmVehiclePO tvp = new TmVehiclePO();
			tvp.setVin(bean.getVin());
			List<TmVehiclePO> ls1 = dao.select(tvp);
			if (ls1!=null&&ls1.size()>0) {
			tvp = ls1.get(0);
			}
			map.put("roNo", bean.getRoNo());
			map.put("vin", bean.getVin());
			map.put("modelId",tvp.getModelId()==null?"-1":tvp.getModelId().toString());
			map.put("companyId", companyId.toString());
			List<TtAsActivityBean> ActivityBeanList = dao.getWorkingHoursInfoList(roId, map,logonUser);// 活动工时
			List<TtAsActivityBean> ActivityPartsList = dao.getPartsList(roId,map,logonUser);// 活动配件
			List<TtAsActivityBean> ActivityNetItemList = dao.getNetItemList(roId, map, logonUser);
			// List<TtAsActivityBean>

			act.setOutData("ActivityBeanList", ActivityBeanList);
			act.setOutData("ActivityPartsList", ActivityPartsList);
			act.setOutData("ActivityNetItemList", ActivityNetItemList);
			request.setAttribute("roId", roId);
			request.setAttribute("roBean", tarp);
			act.setForword(RO_DETAIL_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动管理--活动项目");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: changeRoDetail
	 * @Description: TODO(工单带出工单基本信息到索赔单)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeRoDetail() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		RequestWrapper request = act.getRequest();
		String roId = request.getParamValue("roId");// 活动ID
		
		int newPart=0;
		try { 
			if(null==roId||"null".equalsIgnoreCase(roId)){
				logger.error("changeRoDetail方法中roId为空");
				throw new BizException("roId为空!");
			}
			roId=CommonUtils.checkNull(roId);
			if("".equals(roId)){
				logger.error("changeRoDetail方法中roId为空");
				throw new BizException("roId为空!");
			}
			
			Map<String, String> map = new HashMap<String, String>();
			map.put("roId", roId);
			PageResult<TtAsRepairOrderExtPO> ps = dao.queryRepairOrder(map,
					Constant.PAGE_SIZE, 1);
			List<TtAsRepairOrderExtPO> ls = ps.getRecords();
			TtAsRepairOrderExtPO tarp = new TtAsRepairOrderExtPO();
			if (ls != null) {
				if (ls.size() > 0) {
					tarp = ls.get(0);
				}
			}
			List<Map<String, Object>> isNewPART = dao.viewIsNewPart(roId);
			List<Map<String, Object>> NewPartCodeList = dao.viewIsNewPartString(roId);
			String NewPartCode = "";
			if(NewPartCodeList.size()>0){
				for(int i=0;i<NewPartCodeList.size();i++){
					NewPartCode=NewPartCode+NewPartCodeList.get(i).get("PART_NAME")+",";	
				}
			}
			if(Integer.valueOf(isNewPART.get(0).get("COUNT").toString())>0){
				newPart=1;
			}
			List<Map<String,Object>> jc = dao.queryTcCode();
			int jc_1 = 0;
			if(jc.size()>0){
				jc_1 = Integer.valueOf(jc.get(0).get("CODE_ID").toString());
			}
			request.setAttribute("roId", roId);
			act.setOutData("jc_1", jc_1);
			act.setOutData("roBean", tarp);
			act.setOutData("newPart", newPart);
			act.setOutData("NewPartCode", NewPartCode);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动管理--活动项目");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: changeRoItem
	 * @Description: TODO(工单带出工时)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeRoRepair() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		RequestWrapper request = act.getRequest();
		String roId = request.getParamValue("roId");// 活动ID
		String modelId = request.getParamValue("modelId");
		String itemIds = request.getParamValue("itemIds");
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
		try {
			TtAsRepairOrderPO bean = new TtAsRepairOrderPO();
			bean.setId(Utility.getLong(roId));
			List<TtAsRepairOrderPO> ls = dao.select(bean);
			bean = ls.get(0);
			Map<String,String> map = new HashMap<String,String>();
			map.put("roNo", bean.getRoNo());
			map.put("vin", bean.getVin());
			map.put("isSel", "isSel");
			map.put("itemIds", itemIds);
			map.put("companyId", companyId.toString());
			if (Utility.testString(modelId)) {
				
			}else {
				TmVehiclePO tvp = new TmVehiclePO();
				tvp.setVin(bean.getVin());
				List<TmVehiclePO> lsv = dao.select(tvp);
				if (lsv!=null) {
					if (lsv.size()>0) {
						modelId = lsv.get(0).getModelId()+"";
					}
				}
			}
			map.put("modelId", modelId);
			List<TtAsActivityBean> ActivityBeanList = dao.getWorkingHoursInfoList(roId, map,logonUser);// 活动工时
			//TtAsRoLabourPO tarlp = new TtAsRoLabourPO();
			//tarlp.setRoId(Utility.getLong(roId));
			//TtAsRoLabourPO tarlp1 = new TtAsRoLabourPO();
			//tarlp1.setRoId(Utility.getLong(roId));
			//tarlp1.setIsSel("0");
			//dao.update(tarlp, tarlp1);
			act.setOutData("ActivityBeanList", ActivityBeanList);
			//request.setAttribute("ActivityNetItemList", ActivityNetItemList);
			request.setAttribute("roId", roId);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: changeRoPart
	 * @Description: TODO(工单带出配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeRoPart() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String partAddPer = (String)act.getSession().get(Constant.PART_ADD_PER);
		RequestWrapper request = act.getRequest();
		String roId = request.getParamValue("roId");// 活动ID
		String partIds = request.getParamValue("partIds");
		try {
			TtAsRepairOrderPO bean = new TtAsRepairOrderPO();
			bean.setId(Utility.getLong(roId));
			List<TtAsRepairOrderPO> ls = dao.select(bean);
			bean = ls.get(0);
			Map<String,String> map = new HashMap<String,String>();
			map.put("roNo", bean.getRoNo());
			map.put("vin", bean.getVin());
			map.put("isSel", "isSel");
			map.put("partIds", partIds);
			map.put("partAddPer", partAddPer);
			List<TtAsActivityBean> ActivityPartsList = dao.getPartsList(roId,map,logonUser);// 活动配件
		
			//TtAsRoRepairPartPO tarrp = new TtAsRoRepairPartPO();
			//tarrp.setRoId(Utility.getLong(roId));
			//TtAsRoRepairPartPO tarrp1 = new TtAsRoRepairPartPO();
			//tarrp1.setRoId(Utility.getLong(roId));
			//tarrp1.setIsSel("0");
			//dao.update(tarrp, tarrp1);
			act.setOutData("ActivityPartsList", ActivityPartsList);
			
			request.setAttribute("roId", roId);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动管理--活动项目");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	
	/**
	 * 
	 * @Title: changeRoPart
	 * @Description: TODO(工单带出附件项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void changeRoOther() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		RequestWrapper request = act.getRequest();
		String roId = request.getParamValue("roId");// 活动ID
		String otherIds = request.getParamValue("otherIds");
		try {
			TtAsRepairOrderPO bean = new TtAsRepairOrderPO();
			bean.setId(Utility.getLong(roId));
			List<TtAsRepairOrderPO> ls = dao.select(bean);
			bean = ls.get(0);
			Map<String,String> map = new HashMap<String,String>();
			map.put("roNo", bean.getRoNo());
			map.put("vin", bean.getVin());
			map.put("isSel", "isSel");
			map.put("otherIds", otherIds);
			List<TtAsActivityBean> ActivityNetItemList = dao.getNetItemList(roId,map,logonUser);// 活动配件
			//TtAsRoAddItemPO tarap = new TtAsRoAddItemPO();
			//tarap.setRoId(Utility.getLong(roId));
			//TtAsRoAddItemPO tarap1 = new TtAsRoAddItemPO();
			//tarap1.setRoId(Utility.getLong(roId));
			//tarap1.setIsSel(0);
			//dao.update(tarap, tarap1);
			act.setOutData("ActivityNetItemList", ActivityNetItemList);
			request.setAttribute("roId", roId);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动管理--活动项目");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemWorkHoursQuery
	 * @Description: TODO(工单查询工时)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void roItemWorkHoursQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId");// 活动ID
			String labourCode = request.getParamValue("labourCodes");// 工时代码
			String cnDes = request.getParamValue("cnDess");// 名称
			TtAsActivityBean MantainBean = new TtAsActivityBean();
			MantainBean.setActivityId(roId);
			MantainBean.setLabourCode(labourCode);
			MantainBean.setCnDes(cnDes);
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1;
			Map<String,String> map = new HashMap<String,String>();
			PageResult<Map<String, Object>> ps = dao.getRoItemWorkHoursQuery(
					MantainBean, map,logonUser,curPage, Constant.PAGE_SIZE);
			act.setOutData("ps", ps);
			request.setAttribute("roId", roId);
			act.setForword(RO_ITEM_LABOUR);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔工时信息");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemWorkHoursOption
	 * @Description: TODO(工单新增工时)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void roItemWorkHoursOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId"); // 工单ID
			// String claimId = request.getParamValue("claimId"); //索赔单ID
			String labourId = request.getParamValue("labourId"); // labourId
			String labourCode = request.getParamValue("labourCode"); // 维修项目代码
			String cnDes = request.getParamValue("cnDes"); // 维修项目名称
			String labourHour = request.getParamValue("labourHour"); // 工时数
			if (labourId != null && !"".equals(labourId)) {
				String[] labourIdArray = labourId.split(","); // 取得所有groupIds放在数组中
				// String [] labourCodeArray = labourCode.split(",");
				// //取得所有labourCode放在数组中
				// String [] cnDesArray = cnDes.split(","); //取得所有cnDes放在数组中
				// String [] labourHourArray = labourHour.split(",");
				// //取得所有labourHour放在数组中
				TtAsRoLabourPO RepairitemPO = new TtAsRoLabourPO();
				// TtAsWrLabouritemPO RepairitemPO = new TtAsWrLabouritemPO();
				// RepairitemPO.setId(Long.parseLong(claimId)); //设置索赔单ID
				// RepairitemPO.setCreateBy(logonUser.getUserId());
				// RepairitemPO.setCreateDate(new Date());
				// RepairitemPO.setUpdateBy(logonUser.getUserId());
				// RepairitemPO.setUpdateDate(new Date());
				dao.roItemWorkHoursOption(roId, labourIdArray, logonUser);
				act.setOutData("success", "true");
			}
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "工时信息增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: deleteItemWorkHoursOption
	 * @Description: TODO(工单删除工时)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void deleteItemWorkHoursOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String activityId = request.getParamValue("roId"); // 活动ID
			String itemId = request.getParamValue("itemId"); // itemId
			TtAsRoLabourPO RepairitemPO = new TtAsRoLabourPO();
			RepairitemPO.setId(Long.parseLong(itemId));
			// RepairitemPO.setItemId(Long.parseLong(itemId));
			dao.deleteItemWorkHoursOption(RepairitemPO);
			act.setOutData("success", "true");
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "工时信息增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemPartsQuery
	 * @Description: TODO(工单查询配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void roItemPartsQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId");// 活动ID
			String partNo = request.getParamValue("partNos"); // 配件代码
			String partName = request.getParamValue("partNames"); // 配件名称
			TtAsActivityBean MantainBean = new TtAsActivityBean();
			MantainBean.setActivityId(roId);
			MantainBean.setPartNo(partNo);
			MantainBean.setPartName(partName);
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1;
			Map<String,String> map = new HashMap<String,String>();
			
			PageResult<Map<String, Object>> ps = dao.getRoPartsQuery(
					MantainBean, map,logonUser,curPage, Constant.PAGE_SIZE);
			act.setOutData("ps", ps);
			request.setAttribute("roId", roId);
			act.setForword(RO_ITEM_PART);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "配件信息");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemPartsOption
	 * @Description: TODO(工单新增配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void roItemPartsOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId"); // 活动ID
			String partsId = request.getParamValue("partsId"); // partsId
			String partNo = request.getParamValue("partNo"); // 配件项目代码
			String partName = request.getParamValue("partName"); // 配件项目名称
			String partsQuantityArray = request.getParamValue("PART_QUANTITY");// 配件项目数量
			String claimPrice = request.getParamValue("claimPrice");// 单价
			String supplierCode = request.getParamValue("supplierCode");// 供应商代码
			String supplierName = request.getParamValue("supplierName");// 供应商名称
			if (partsId != null && !"".equals(partsId)) {
				String[] partsIdArray = partsId.split(","); // 取得所有partsId放在数组中
				//String[] partNoArray = partNo.split(","); // 取得所有partNo放在数组中
				//String[] partNameArray = partName.split(","); // 取得所有partName放在数组中
				//String[] partsQuantityArrays = null;
				String[] claimPriceArray = null;
				String[] supplierCodeArray = null;
				String[] supplierNameArray = null;
				/*if (null != partsQuantityArray
						&& !"".equals(partsQuantityArray)
						&& !",".equals(partsQuantityArray)) {
					//partsQuantityArrays = partsQuantityArray.split(","); // 取得所有partsQuantity放在数组中
				}
				if (null != claimPrice && !"".equals(claimPrice)) {
					claimPriceArray = claimPrice.split(","); // 取得所有单价放在数组中
				}
				if (null != supplierCode && !"".equals(supplierCode)) {
					supplierCodeArray = supplierCode.split(","); // 取得所有供应商代码放在数组中
				}
				if (null != supplierName && !"".equals(supplierName)) {
					supplierNameArray = supplierName.split(","); // 取得所有供应商名称放在数组中
				}*/
				/*
				 * TtAsActivityPartsPO PartsPO =new TtAsActivityPartsPO();
				 * PartsPO.setActivityId(Long.parseLong(activityId));
				 * PartsPO.setCreateBy(logonUser.getUserId());
				 * PartsPO.setCreateDate(new Date());
				 * PartsPO.setUpdateBy(logonUser.getUserId());
				 * PartsPO.setUpdateDate(new Date());
				 */
				dao.roItemPartsOption(roId, partsIdArray, logonUser);
				act.setOutData("success", "true");
			}
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "配件信息增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: deleteItemPartsOption
	 * @Description: TODO(工单删除配件)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void deleteItemPartsOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId"); // 活动ID
			String partsId = request.getParamValue("partsId"); // itemId
			TtAsRoRepairPartPO PartsPO = new TtAsRoRepairPartPO();
			PartsPO.setId(Long.parseLong(partsId));
			// PartsPO.setPartsId(Long.parseLong(partsId));
			dao.deleteItemPartsOption(PartsPO);
			act.setOutData("success", "true");
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "配件信息增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemOthersQuery
	 * @Description: TODO(工单查询其他项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void roItemOthersQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId"); // 活动ID
			// String partNo=request.getParamValue("partNo"); //配件代码
			// String partName=request.getParamValue("partName"); //配件名称
			TtAsActivityBean MantainBean = new TtAsActivityBean();
			MantainBean.setActivityId(roId);
			// MantainBean.setPartNo(partNo);
			// MantainBean.setPartName(partName);
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1;
			PageResult<Map<String, Object>> ps = dao.getRoOthersQuery(MantainBean, curPage, Constant.PAGE_SIZE);
			act.setOutData("ps", ps);
			request.setAttribute("roId", roId);
			act.setForword(RO_ITEM_OTHER);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "配件信息");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: roItemOthersOption
	 * @Description: TODO(工单新增其他项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void roItemOthersOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String roId = request.getParamValue("roId"); // 活动ID
			String id = request.getParamValue("id"); // ID
			String itemCode = request.getParamValue("itemCode"); // 项目代码
			String itemDesc = request.getParamValue("itemDesc"); // 项目名称
			if (id != null && !"".equals(id)) {
				String[] idArray = id.split(","); // 取得所有id放在数组中
				//String[] itemCodeArray = itemCode.split(","); // 取得所有itemCode放在数组中
				//String[] itemDescArray = itemDesc.split(","); // 取得所有itemDesc放在数组中
				/*
				 * TtAsActivityNetitemPO NetitemPO =new TtAsActivityNetitemPO();
				 * NetitemPO.setActivityId(Long.parseLong(activityId));
				 * NetitemPO.setCreateBy(logonUser.getUserId());
				 * NetitemPO.setCreateDate(new Date());
				 * NetitemPO.setUpdateBy(logonUser.getUserId());
				 * NetitemPO.setUpdateDate(new Date());
				 */
				dao.roItemOthersOption(roId, idArray, logonUser);
				act.setOutData("success", "true");
			}
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "配件信息增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}

	/**
	 * 
	 * @Title: deleteItemOthersOption
	 * @Description: TODO(工单删除其他项目)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	@SuppressWarnings("static-access")
	public void deleteItemOthersOption() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String activityId = request.getParamValue("roId"); // 活动ID
			String id = request.getParamValue("id"); // itemId
			TtAsRoAddItemPO PartsPO = new TtAsRoAddItemPO();
			PartsPO.setRoId(Long.parseLong(activityId));
			PartsPO.setId(Long.parseLong(id));
			dao.deleteItemOthersOption(PartsPO);
			act.setOutData("success", "true");
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "附加项目增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: selAllOptions 
	* @Description: TODO(选择其他项目，工时，配件) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void selAllOptions () {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			roItemOthersOption();
			roItemPartsOption();
			roItemWorkHoursOption();
			act.setOutData("success", true);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "附加项目增加");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
		
	}

	/**
	 * 
	 * @Title: queryRepairOrder
	 * @Description: TODO(工单信息查询)
	 * @param 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void queryRepairOrder() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		Long companyId = GetOemcompanyId.getOemCompanyId(logonUser);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			String roId = request.getParamValue("roId"); // 活动ID
			String roNo = request.getParamValue("RO_NO"); // 工单号
			String vin = request.getParamValue("VIN"); // 工单号
			String id = request.getParamValue("id"); // itemId
			String roStatus = request.getParamValue("roStatus");
			String customerName = request.getParamValue("CUSTOMER_NAME"); //车主姓名
			String licenseNo = request.getParamValue("LICENSE_NO");
			String repairType = request.getParamValue("REPAIR_TYPE");
			String modelId = request.getParamValue("MODEL_ID");
			String balanceDateStart = request.getParamValue("BALANCE_DATE_START");
			String balanceDateEnd = request.getParamValue("BALANCE_DATE_END");
			String createDateStr = request.getParamValue("CREATE_DATE_STR");
			String createDateEnd = request.getParamValue("CREATE_DATE_END");
			String isApp = request.getParamValue("isApp");
			Map<String, String> map = new HashMap<String, String>();
			map.put("roId", roId);
			map.put("roNo", roNo);
			map.put("vin", vin);
			map.put("roStatus", roStatus);
			map.put("dealerId", dealerId);
			map.put("balanceDateStart", balanceDateStart);
			map.put("balanceDateEnd", balanceDateEnd);
			map.put("repairType", repairType);
			map.put("modelId", modelId);
			map.put("licenseNo", licenseNo);
			map.put("customerName", customerName);
			map.put("createDateStr", createDateStr);
			map.put("createDateEnd", createDateEnd);
			if (Utility.testString(isApp)) {
				map.put("isApp", "isApp");
			}
			PageResult<TtAsRepairOrderExtPO> ps = dao.queryRepairOrder(map,
					Constant.PAGE_SIZE, curPage);
			act.setOutData("ps", ps);
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "工单信息查询");
			logger.error(logonUser, e1);
			act.setException(e1);
		}

	}
	
	/*------------------质量信息跟踪卡---------------*/
	/**
	 * 
	* @Title: infoAddForward 
	* @Description: TODO(质量信息新增跳转) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void infoAddForward(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			String claimId = request.getParamValue("claimId");
			String detail = request.getParamValue("detail");
			String infoId = request.getParamValue("infoId");
			
			TmDealerPO tdp = new TmDealerPO();
			tdp.setDealerId(Utility.getLong(dealerId));
			List<TmDealerPO> lsd = dao.select(tdp);
			if (lsd != null) {
				if (lsd.size() > 0) {
					tdp = lsd.get(0);
				}
			}
			TtAsWrInformationqualityExtPO tawep = new TtAsWrInformationqualityExtPO();
			//tawep.setClaimId(Utility.getLong(claimId));
			tawep = dao.queryInfoByClaimId(claimId);
			if (Utility.testString(claimId)) {
				
			}else {
				if (Utility.testString(infoId)){
					tawep=dao.queryInfoByClaimInfoId(infoId);
				}
			}
			if ("1".equals(detail)) {
				act.setForword(INFO_DETAIL_URL);
			}else{
				act.setForword(INFO_ADD_URL);
			}
			act.setOutData("info",tawep);
			act.setOutData("claimId", claimId);
			act.setOutData("dealerName", tdp.getDealerName());
			act.setOutData("dealerCode", tdp.getDealerCode());
		} catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "质量信息");
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: infoInsert 
	* @Description: TODO(质量信息新增) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void infoInsert() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		try {
			RequestWrapper request = act.getRequest();
			
			String claimId = request.getParamValue("claimId"); 
			String dealerCode = request.getParamValue("DEALER_CODE");
			String complainSort = request.getParamValue("COMPLAIN_SORT");
			String dealerName = request.getParamValue("DEALER_NAME");
			String tel = request.getParamValue("TEL");
			String infomationSort = request.getParamValue("INFOMATION_SORT");
			String currentDate = request.getParamValue("CURRENT_DATE");
			String vin = request.getParamValue("VIN");
			String modelCode = request.getParamValue("MODEL_CODE");
			String modelName = request.getParamValue("MODEL_NAME");
			String engineNo = request.getParamValue("ENGINE_NO");
			String factoryDate = request.getParamValue("FACTORY_DATE");
			String purchasedDate = request.getParamValue("PURCHASED_DATE");
			String mileage = request.getParamValue("MILEAGE");
			String customerName = request.getParamValue("CUSTOMER_NAME");
			String phone = request.getParamValue("PHONE");
			String questionPart = request.getParamValue("QUESTION_PART");
			String faultNature = request.getParamValue("FAULT_NATURE");
			String gearboxNature = request.getParamValue("GEARBOX_NATURE");
			String vhclUse = request.getParamValue("VHCL_USE");
			String speedCase = request.getParamValue("SPEED_CASE");
			String roadCase = request.getParamValue("ROAD_CASE");
			String loadingCase = request.getParamValue("LOADING_CASE");
			String adptCase = request.getParamValue("ADPT_CASE");
			String produceFactory = request.getParamValue("PRODUCE_FACTORY");
			String completeEngineno = request.getParamValue("COMPLETE_ENGINENO");
			String faultOpinion = request.getParamValue("FAULT_OPINION");
			String damageCase = request.getParamValue("DAMAGE_CASE");
			String damagePrice = request.getParamValue("DAMAGE_PRICE");
			String processOpinion = request.getParamValue("PROCESS_OPINION");
			String result = request.getParamValue("RESULT");
			String booker = request.getParamValue("BOOKER");
			String backUnit = request.getParamValue("BACK_UNIT");
			String backDate = request.getParamValue("BACK_DATE");
			String caseWork = request.getParamValue("CASE_WORK");
			String questionCase = request.getParamValue("QUESTION_CASE");
			String conntion = request.getParamValue("CONNTION");
			String dutyUnit = request.getParamValue("DUTY_UNIT");
			String tempStep = request.getParamValue("TEMP_STEP");
			String forveStep = request.getParamValue("FORVE_STEP");
			String suggest = request.getParamValue("SUGGEST");
			String serviceOpinion = request.getParamValue("SERVICE_OPINION");
			
			Date date  = new Date();
			TtAsWrInformationqualityPO taip = new TtAsWrInformationqualityPO();
			String infoId = SequenceManager.getSequence("");
			taip.setId(Utility.getLong(infoId));
			taip.setBillNo(SequenceManager.getSequence("IQ"));
			taip.setClaimId(Utility.getLong(claimId)); //
			taip.setDealerCode(dealerCode);
			taip.setDealerName(dealerName);
			taip.setComplainSort(Utility.getInt(complainSort));
			taip.setTel(tel);
			taip.setInformationSort(Utility.getInt(infomationSort));
			taip.setCurrentDate(Utility.getDate(currentDate, 1));
			taip.setVin(vin);
			taip.setModelCode(modelCode);
			taip.setModelName(modelName);
			taip.setEngineNo(engineNo);
			taip.setFactoryDate(Utility.getDate(factoryDate, 1));
			taip.setPurchasedDate(Utility.getDate(purchasedDate, 1));
			taip.setMileage(Utility.getDouble(mileage));
			taip.setCustomName(customerName);
			taip.setPhone(phone);
			taip.setQuestionPart(Utility.getInt(questionPart));
			taip.setFaultNatrue(Utility.getInt(faultNature));
			taip.setGearboxNatrue(Utility.getInt(gearboxNature));
			taip.setVhclUse(vhclUse);
			taip.setSpeedCase(speedCase);
			taip.setRoadCase(roadCase);
			taip.setLoadingCase(loadingCase);
			taip.setAdaptCase(adptCase);
			taip.setProduceFactroy(produceFactory);
			taip.setCompleteEngineno(completeEngineno);
			taip.setFaultOpinion(faultOpinion);
			taip.setDamageCase(damageCase);
			taip.setDamagePrice(Utility.getDouble(damagePrice));
			taip.setProcessOpinion(processOpinion);
			taip.setResult(result);
			taip.setBooker(booker);
			taip.setBackUnit(backUnit);
			taip.setBackDate(Utility.getDate(backDate, 1));
			taip.setCaseWork(caseWork);
			taip.setQuestionCase(questionCase);
			taip.setConntion(conntion);
			taip.setDutyUnit(dutyUnit);
			taip.setTempStep(tempStep);
			taip.setForveStep(forveStep);
			taip.setSuggest(suggest);
			taip.setServiceOpinion(serviceOpinion);
			taip.setCreateBy(logonUser.getUserId());
			taip.setCreateDate(date);
			
			dao.insert(taip);
			act.setOutData("success", true); //插入成功，关闭信息页
			act.setOutData("infoId", infoId);
		}catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "质量信息");
			act.setOutData("success", false);
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: infoUpdate 
	* @Description: TODO(质量信息修改) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void infoUpdate() {

		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(
				Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String claimId = request.getParamValue("claimId"); 
			String billNo = request.getParamValue("billNo");
			String infoId = request.getParamValue("infoSubId");
			String dealerCode = request.getParamValue("DEALER_CODE");
			String complainSort = request.getParamValue("COMPLAIN_SORT");
			String dealerName = request.getParamValue("DEALER_NAME");
			String tel = request.getParamValue("TEL");
			String infomationSort = request.getParamValue("INFOMATION_SORT");
			String currentDate = request.getParamValue("CURRENT_DATE");
			String vin = request.getParamValue("VIN");
			String modelCode = request.getParamValue("MODEL_CODE");
			String modelName = request.getParamValue("MODEL_NAME");
			String engineNo = request.getParamValue("ENGINE_NO");
			String factoryDate = request.getParamValue("FACTORY_DATE");
			String purchasedDate = request.getParamValue("PURCHASED_DATE");
			String mileage = request.getParamValue("MILEAGE");
			String customerName = request.getParamValue("CUSTOMER_NAME");
			String phone = request.getParamValue("PHONE");
			String questionPart = request.getParamValue("QUESTION_PART");
			String faultNature = request.getParamValue("FAULT_NATURE");
			String gearboxNature = request.getParamValue("GEARBOX_NATURE");
			String vhclUse = request.getParamValue("VHCL_USE");
			String speedCase = request.getParamValue("SPEED_CASE");
			String roadCase = request.getParamValue("ROAD_CASE");
			String loadingCase = request.getParamValue("LOADING_CASE");
			String adptCase = request.getParamValue("ADPT_CASE");
			String produceFactory = request.getParamValue("PRODUCE_FACTORY");
			String completeEngineno = request.getParamValue("COMPLETE_ENGINENO");
			String faultOpinion = request.getParamValue("FAULT_OPINION");
			String damageCase = request.getParamValue("DAMAGE_CASE");
			String damagePrice = request.getParamValue("DAMAGE_PRICE");
			String processOpinion = request.getParamValue("PROCESS_OPINION");
			String result = request.getParamValue("RESULT");
			String booker = request.getParamValue("BOOKER");
			String backUnit = request.getParamValue("BACK_UNIT");
			String backDate = request.getParamValue("BACK_DATE");
			String caseWork = request.getParamValue("CASE_WORK");
			String questionCase = request.getParamValue("QUESTION_CASE");
			String conntion = request.getParamValue("CONNTION");
			String dutyUnit = request.getParamValue("DUTY_UNIT");
			String tempStep = request.getParamValue("TEMP_STEP");
			String forveStep = request.getParamValue("FORVE_STEP");
			String suggest = request.getParamValue("SUGGEST");
			String serviceOpinion = request.getParamValue("SERVICE_OPINION");
			
			Date date  = new Date();
			TtAsWrInformationqualityPO taip0 = new TtAsWrInformationqualityPO();
			taip0.setId(Utility.getLong(infoId));
			TtAsWrInformationqualityPO taip = new TtAsWrInformationqualityPO();
			taip.setId(Utility.getLong(infoId));
			taip.setClaimId(Utility.getLong(claimId)); //不插入索赔ID，待总提交时对信息表进行更新
			taip.setDealerCode(dealerCode);
			taip.setDealerName(dealerName);
			taip.setComplainSort(Utility.getInt(complainSort));
			taip.setTel(tel);
			taip.setInformationSort(Utility.getInt(infomationSort));
			taip.setCurrentDate(Utility.getDate(currentDate, 1));
			taip.setVin(vin);
			taip.setModelCode(modelCode);
			taip.setModelName(modelName);
			taip.setEngineNo(engineNo);
			taip.setFactoryDate(Utility.getDate(factoryDate, 1));
			taip.setPurchasedDate(Utility.getDate(purchasedDate, 1));
			taip.setMileage(Utility.getDouble(mileage));
			taip.setCustomName(customerName);
			taip.setPhone(phone);
			taip.setQuestionPart(Utility.getInt(questionPart));
			taip.setFaultNatrue(Utility.getInt(faultNature));
			taip.setGearboxNatrue(Utility.getInt(gearboxNature));
			taip.setVhclUse(vhclUse);
			taip.setSpeedCase(speedCase);
			taip.setRoadCase(roadCase);
			taip.setLoadingCase(loadingCase);
			taip.setAdaptCase(adptCase);
			taip.setProduceFactroy(produceFactory);
			taip.setCompleteEngineno(completeEngineno);
			taip.setFaultOpinion(faultOpinion);
			taip.setDamageCase(damageCase);
			taip.setDamagePrice(Utility.getDouble(damagePrice));
			taip.setProcessOpinion(processOpinion);
			taip.setResult(result);
			taip.setBooker(booker);
			taip.setBackUnit(backUnit);
			taip.setBackDate(Utility.getDate(backDate, 1));
			taip.setCaseWork(caseWork);
			taip.setQuestionCase(questionCase);
			taip.setConntion(conntion);
			taip.setDutyUnit(dutyUnit);
			taip.setTempStep(tempStep);
			taip.setForveStep(forveStep);
			taip.setSuggest(suggest);
			taip.setServiceOpinion(serviceOpinion);
			taip.setCreateBy(logonUser.getUserId());
			taip.setCreateDate(date);
			
			dao.update(taip0,taip);
			act.setOutData("success", true); //修改成功，关闭信息页
			act.setOutData("infoId", infoId);
		}catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "质量信息");
			act.setOutData("success", false);
			logger.error(logonUser, e1);
			act.setException(e1);
		}
	
	}
	/**
	 * 
	* @Title: showActivityForward 
	* @Description: TODO(查询服务活动跳转) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void showActivityForward() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String vin = request.getParamValue("vin");
			String inMileage = request.getParamValue("IN_MILEAGE");
			
			if (Utility.testString(inMileage)) {
				
			}else {
				inMileage = "0";
			}
			act.setOutData("vin", vin);
			act.setOutData("inMileage", inMileage);
			act.setForword(ACTIVITY_URL);
		}catch (Exception e) {
			BizException e1 = new BizException(act, e,
					ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动信息");
			act.setOutData("success", false);
			logger.error(logonUser, e1);
			act.setException(e1);
		}	
		
	}
	/**
	 * 
	* @Title: queryActivity 
	* @Description: TODO(查询服务活动页面) 
	* @param     设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public void queryActivity() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		String dealerId = logonUser.getDealerId();
		String dealerCode = logonUser.getDealerCode();
		try {
			Map<String,String> map = new HashMap<String,String>();
			RequestWrapper request = act.getRequest();
			Integer curPage = request.getParamValue("curPage") != null ? Integer
					.parseInt(request.getParamValue("curPage"))
					: 1; // 处理当前页
			String vin = request.getParamValue("vin"); 
			String inMileage = request.getParamValue("inMileage");  
			String activityCode = request.getParamValue("ACTIVITY_CODE");
			String activityName = request.getParamValue("ACTIVITY_NAME");
			String modelId = "";
			String yieldly = "";
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date proDate = null;
			Date purDate = null;
			String proDateStr = "";
			String purDateStr = "";
			TmVehiclePO tvp = new TmVehiclePO();
			if (Utility.testString(vin))
			tvp.setVin(vin);
			else 
			tvp.setVin("-1");
			List<TmVehiclePO> lsv = dao.select(tvp);
			if (lsv!=null) {
				if (lsv.size()>0) {
					tvp = lsv.get(0);
					modelId = tvp.getModelId()+"";
					proDate = tvp.getProductDate();
					if (proDate!=null) {
						proDateStr = sf.format(proDate);
					}
					purDate = tvp.getPurchasedDate();
					if (purDate!=null) {
						purDateStr = sf.format(purDate);
					}
					yieldly = tvp.getYieldly();
				}else {
					act.setOutData("noCar", true); //无该车信息
				}
			}else {
				act.setOutData("noCar", true); //无该车信息
			}
			map.put("vin", vin);
			map.put("dealerCode", dealerCode);
			map.put("proDate",proDateStr);
			map.put("yieldly", yieldly);
			map.put("purDate", purDateStr);
			map.put("dealerId", dealerId);
			map.put("modelId", modelId);
			map.put("activityCode", activityCode);
			map.put("activityName", activityName);
			map.put("inMileage", inMileage);
			PageResult<TtAsActivityPO> ps = dao.queryActivityComboByVin(map,curPage,Constant.PAGE_SIZE);
			act.setOutData("ps", ps);
			
		}catch (Exception e) {
			BizException e1 = new BizException(act, e,ErrorCodeConstant.QUERY_FAILURE_CODE, "服务活动信息");
			act.setOutData("success", false);
			logger.error(logonUser, e1);
			act.setException(e1);
		}	
		
	}
	
	  /**
	   * 车型免费保养历史记录
	   * 规则：从维修工单中统计出对应该车辆的保养类型维修历史记录
	   *      和服务活动类型的工单（服务活动类型为保养）
	   * 呈现信息：1."工单号码"2."工单日期"3."经销商名称"4."保养次数"5."保养费用"6."行驶里程"
	   */
	  public void freeMaintainHistory(){
		    ActionContext act = ActionContext.getContext();
		    AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		    try {
		      RequestWrapper request = act.getRequest();
		      String vin = request.getParamValue("VIN");
		      List<Map<String,Object>> freeMaintaimHisList = dao.freeMaintainHistory(vin);
		      
		      act.setOutData("freeMaintaimHisList", freeMaintaimHisList);
		      act.setOutData("VIN", vin);
		      act.setForword(this.FREEMAINTAIM_HIS_URL);
		    }catch (Exception e) {
		      BizException e1 = new BizException(act, e,
		          ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆维修历史记录");
		      act.setOutData("success", false);
		      logger.error(logonUser, e1);
		      act.setException(e1);
		    } 
	  }
	  
	  /**
	   * 维修历史记录
	   * 规则：从索赔单中统计出对应车辆"一般维修","售前维修","外出维修"类型索赔单
	   * 呈现信息：1."索赔单号码"2."维修日期"3."经销商名称"4."行驶里程"5."工时代码"6."工时名称"7."配件代码"8."配件名称"
	   */
	  public void maintaimHistory(){
	    
	    ActionContext act = ActionContext.getContext();
	    AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
	    try {
	      RequestWrapper request = act.getRequest();
	      String vin = request.getParamValue("VIN");
	      String claimTypes = "" + Constant.CLA_TYPE_01 + "," + Constant.CLA_TYPE_07 
	                + "," + Constant.CLA_TYPE_09;
	      List<Map<String,Object>> maintaimHisList = dao.maintaimHistory(vin, claimTypes);
	      
	      act.setOutData("maintaimHisList", maintaimHisList);
	      act.setOutData("VIN", vin);
	      act.setForword(this.MAINTAIN_HIS_URL);
	    }catch (Exception e) {
	      BizException e1 = new BizException(act, e,
	          ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆维修历史记录");
	      act.setOutData("success", false);
	      logger.error(logonUser, e1);
	      act.setException(e1);
	    }  
	  }
	  
	  /**
	   * 授权历史记录
	   * 规则：历史索赔单的技术室授权历史(经过人工审核或自动审核的索赔单) 
	   * 呈现信息：1."索赔单号吗"2."经销商名称"3."授权时间"4."授权人"5."授权结果"6."授权备注"7."工时名称"8."配件名称" 
	   */
	  public void auditingHistory(){
	    
	    ActionContext act = ActionContext.getContext();
	    AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
	    try {
	      RequestWrapper request = act.getRequest();
	      String vin = request.getParamValue("VIN");
	      String expStatus = Constant.CLAIM_APPLY_ORD_TYPE_01.toString();
	      List<Map<String,Object>> auditingHisList = dao.auditingHistory(vin, expStatus);
	      
	      act.setOutData("auditingHisList", auditingHisList);
	      act.setOutData("VIN", vin);
	      act.setForword(this.AUDITING_HIS_URL);
	    }catch (Exception e) {
	      BizException e1 = new BizException(act, e,
	          ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆授权历史记录");
	      act.setOutData("success", false);
	      logger.error(logonUser, e1);
	      act.setException(e1);
	    }
	  }
	  
	  /**
	   * 
	  * @Title: getPartPrice 
	  * @Description: TODO(根据partCode和supplierCode取得配件索赔价格) 
	  * @param     设定文件 
	  * @return void    返回类型 
	  * @throws
	   */
	  public void getPartPrice() {
		  ActionContext act = ActionContext.getContext();
	    AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
	    String partAddPer = (String)act.getSession().get(Constant.PART_ADD_PER);
	    try {
	      RequestWrapper request = act.getRequest();
	      String partCode = request.getParamValue("partCode");
	      String supplierCode = request.getParamValue("supplierCode");
	      Map<String,String> map = new HashMap();
	      map.put("partCode", partCode);
	      if ("UNKNOWN".equals(supplierCode)) {//如果选择位置不放入MAP
	    	  
	      }else {
	      map.put("supplierCode",supplierCode);
	      }
	      TmPtPartBasePO tp = dao.getPartPrice(map);
	      Float claimPrice = tp.getClaimPrice()==null?0f:tp.getClaimPrice();
	      Float partAddPerFloat = Utility.getFloat(partAddPer);
	      claimPrice = claimPrice*(1+partAddPerFloat);
	      act.setOutData("claimPrice", claimPrice);
	    }catch (Exception e) {
	      BizException e1 = new BizException(act, e,
	          ErrorCodeConstant.QUERY_FAILURE_CODE, "车辆授权历史记录");
	      act.setOutData("success", false);
	      logger.error(logonUser, e1);
	      act.setException(e1);
		}
	  }
	  
	  /**
	   * 售前车辆 检测规则
	   * 规则：当 车辆 未卖出前（售前车辆，无实效记录）时
	   *       索赔单类型只能为 服务活动 和 售前维修
	   */
	  public void checkUnSaleVechile(){
		  
		  ActionContext act = ActionContext.getContext();
		  AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		  try{
			  RequestWrapper request = act.getRequest();
			  String vin = request.getParamValue("vin");
			  String claimType = request.getParamValue("claimType");
			  
			  boolean isSale = true;
			  if(Constant.CLA_TYPE_06.toString().equals(claimType) || Constant.CLA_TYPE_07.toString().equals(claimType)){//服务活动或售前维修不用验证对应车辆
				  isSale = true;
			  }else{//其他类型需要验证对应车辆是否存在销售记录
				  List<TtDealerActualSalesPO> saleList = dao.checkUnSaleVechile(vin);
				  if(saleList==null || saleList.size()<1){
					  isSale = false;
				  }
			  }
			  
			  act.setOutData("isSale", isSale);
		  }catch(Exception e){
			  BizException e1 = new BizException(act, e,
			          ErrorCodeConstant.QUERY_FAILURE_CODE, "售前车辆 检测规则");
		      act.setOutData("success", false);
		      logger.error(logonUser, e1);
		      act.setException(e1);
		  }
	  }
	  
	  /*
	   * 保养状态判定
	   */
	  public void maintainStateSet(){
		  ActionContext act = ActionContext.getContext();
		  AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		  try{
			  RequestWrapper request = act.getRequest();
			  String vin = request.getParamValue("VIN");
			  String mile = request.getParamValue("mile");
			  String roNo = request.getParamValue("ro_no");
			  
			  List<Map<String,Object>> list = dao.getMaintainStateSet(vin);
			  if(list.size()>0){
				  act.setOutData("map", list.get(0));
				  Date now = new Date(); //今天
					
				  String formatStyle ="yyyy-MM-dd";  
				  SimpleDateFormat df = new SimpleDateFormat(formatStyle);  
				  String d1 = (String)list.get(0).get("SALES_DATE");
				  String d2 = df.format(now);
				  int month  = Utility.compareDate(d1,d2,1); //取得今日和保养开始时间的插值
				  int day = Utility.compareDate(d1, d2, 0); //取得今日和保养开始时间的插值 天数
					
				  List<TtAsWrQamaintainPO> lsq = dao.getFree(Integer.parseInt(list.get(0).get("FREE_TIMES").toString())+1,logonUser.getCompanyId(), month, day, Double.parseDouble(mile));
				  if(lsq.size()>0){
					  act.setOutData("flag", Constant.IF_TYPE_NO.toString());
				  }else{
					  act.setOutData("flag", Constant.IF_TYPE_YES.toString());
				  }
				  
				  act.setOutData("mile", mile);
				  act.setOutData("days", day);
				  act.setOutData("now", d2);
				  
				//预授权状态
				  Integer preClaimStatus = null;
				  String preClaimYN = Constant.IF_TYPE_NO.toString();
				  //判定是否存在工单
				  if(StringUtil.notNull(roNo)){
					  TtAsRepairOrderPO ropo = new TtAsRepairOrderPO();
					  ropo.setRoNo(roNo);
					  List<TtAsRepairOrderPO> roList = dao.select(ropo);
					  if(roList.size()>0){
						  preClaimStatus = roList.get(0).getForlStatus();
						  if(preClaimStatus!=null)
							  preClaimYN = Constant.IF_TYPE_YES.toString();
					  }
				  }
				  
				  act.setOutData("preClaimYN", preClaimYN);
				  act.setOutData("preClaimStatus", preClaimStatus);
				  act.setForword(MAINTAIN_STATE_SET_URL);
			  }
			  else{
				  act.setOutData("map",null);
			  }
		  }catch(Exception e){
			  BizException e1 = new BizException(act, e,
			          ErrorCodeConstant.QUERY_FAILURE_CODE, "售前车辆 检测规则");
		      act.setOutData("success", false);
		      logger.error(logonUser, e1);
		      act.setException(e1);
		  }
	  }
	  /*
	   * 配件三包判定
	   */
	  public void threePackageSet(){
		  ActionContext act = ActionContext.getContext();
		  AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		  try{
			  RequestWrapper request = act.getRequest();
			  String vin = request.getParamValue("VIN");
			  String mile = request.getParamValue("mile");
			  String codes = request.getParamValue("codes");
			  String roNo = request.getParamValue("roNo");

			  Date now = new Date(); //今天
			  List<Map<String,Object>> list = dao.getMaintainStateSet(vin);
			  //取得工单开始时间
			  if(StringUtil.notNull(roNo) && !"null".equals(roNo)){
				  TtAsRepairOrderPO po = new TtAsRepairOrderPO() ;
				  po.setRoNo(roNo);
				  List list2 = dao.select(po) ;
				  if(list2.size()>0)
					  now = ((TtAsRepairOrderPO)list2.get(0)).getRoCreateDate() ;
			  }
			  if(list.size()>0){
				  act.setOutData("map", list.get(0));
					
				  String formatStyle ="yyyy-MM-dd";  
				  SimpleDateFormat df = new SimpleDateFormat(formatStyle);  
				  String d1 = (String)list.get(0).get("SALES_DATE");
				  String d2 = df.format(now);
				  int month  = Utility.compareDate(d1,d2,1); //取得今日和保养开始时间的插值
				  int day = Utility.compareDate(d1, d2, 0); //取得今日和保养开始时间的插值 天数
				  Long comId ;
				  if(StringUtil.notNull(logonUser.getOemCompanyId())){
					  comId = Long.parseLong(logonUser.getOemCompanyId()) ;
				  } else
					  comId = logonUser.getCompanyId() ;
				  
				  List<TtAsWrQamaintainPO> lsq = dao.getFree2(Integer.parseInt(list.get(0).get("FREE_TIMES").toString())+1,comId, month, day, Double.parseDouble(mile));
				  if(lsq.size()>0){
					  act.setOutData("flag", "正常");

					  //判定配件是否三包
					  if(codes!=null){
						  String[] cs = codes.split(",") ;
						  List<NewPartBean> nlist = new ArrayList() ;
						  for(int i=0;i<cs.length;i++){
							  List<NewPartBean> l = dao.getNewPartBean(cs[i],vin);
							  
							  if(l.size()<=0)
								  l = dao.getNewPartBean2(cs[i]);
							  
							  nlist.add(l.get(0)) ;
						  }
						  WrRuleUtil util = new WrRuleUtil();
						  WarrantyPartVO wp = null;
						  for(int i=0;i<nlist.size();i++){
							  //try{}catch{}的原因是针对此配件，没定义三包就默认为不是三包的
							  try{
								  wp = util.wrRuleCompute2(d2,mile, list.get(0).get("SALES_DATE")!=null?list.get(0).get("SALES_DATE").toString():null, vin, nlist.get(i).getPartCode());
								  nlist.get(i).setIsWarranty(wp.getIsInWarranty());
							  }catch(Exception e){
								  nlist.get(i).setIsWarranty(Constant.IF_TYPE_NO);
							  }
						  }
						  
						  act.setOutData("nlist",nlist);
					  }
				  }else{
					  if(codes!=null){
						  String[] cs = codes.split(",") ;
						  List<NewPartBean> nlist = new ArrayList() ;
						  for(int i=0;i<cs.length;i++){
							  List<NewPartBean> l = dao.getNewPartBean(cs[i],vin);
							  if(l.size()<=0){
								  //没有为此配件单独定义三包规则，则取此规则下的通用规则定义
								  l = dao.getNewPartBean2(cs[i]);
							  }
							  nlist.add(l.get(0)) ;
						  }
						  WrRuleUtil util = new WrRuleUtil();
						  WarrantyPartVO wp = null;
						  for(int i=0;i<nlist.size();i++){
							  //try{}catch{}的原因是针对此配件，没定义三包就默认为不是三包的
							  try{
								  wp = util.wrRuleCompute2(d2,mile, list.get(0).get("SALES_DATE")!=null?list.get(0).get("SALES_DATE").toString():null, vin, nlist.get(i).getPartCode());
								  nlist.get(i).setIsWarranty(wp.getIsInWarranty());
							  }catch(Exception e){
								  nlist.get(i).setIsWarranty(Constant.IF_TYPE_NO);
							  }
						  }
						  act.setOutData("nlist",nlist);
					  }
					  act.setOutData("flag", "已脱保");
				  }
				  
				  act.setOutData("mile", mile);
				  act.setOutData("days", day);
				  act.setOutData("month", month);
				  act.setOutData("now", d2);
				  act.setOutData("yes", Constant.IF_TYPE_YES);
				  act.setOutData("no",Constant.IF_TYPE_NO);
			  }
			  
			  act.setForword(THREE_PACKAGE_SET_URL);
		  }catch(Exception e){
			  BizException e1 = new BizException(act, e,
			          ErrorCodeConstant.QUERY_FAILURE_CODE, "售前车辆 检测规则");
		      act.setOutData("success", false);
		      logger.error(logonUser, e1);
		      act.setException(e1);
		  }
	  }
	  public void viewEngineNo(){
		  ActionContext act = ActionContext.getContext();
		  AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
		  RequestWrapper request = act.getRequest();
		  String vin = request.getParamValue("VIN");
		  String engineNo = request.getParamValue("ENGINE_NO");
		  List<TmVehiclePO> list = dao.getCar(vin);
		  Integer  is_a = 0;
		  if(list.size()>0){
			  if(list.get(0).getEngineNo().equals(engineNo)){
				  is_a=1;
			  }
		  }
		  act.setOutData("is_a", is_a);
	  }
	  
		/**
		 * 
		 * @Title: selectMainPartCodeForward
		 * @Description: TODO(选择页面跳转主配件)
		 * @param 设定文件
		 * @return void 返回类型
		 * @throws
		 */
		public void selectRulePartCodeForward() {
			ActionContext act = ActionContext.getContext();
			AclUserBean logonUser = (AclUserBean) act.getSession().get(
					Constant.LOGON_USER);
			try {
				RequestWrapper request = act.getRequest();
				String roNo = request.getParamValue("roNo");
				String vin = request.getParamValue("vin");
				String groupId = request.getParamValue("GROUP_ID");
				act.setOutData("roNo", roNo);
				act.setOutData("vin", vin);
				act.setOutData("GROUP_ID", groupId);
				act.setForword(RULE_PARTCODE_URL);
			} catch (Exception e) {
				BizException e1 = new BizException(act, e,
						ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
				logger.error(logonUser, e1);
				act.setException(e1);
			}

		}
	  
	  /**
		 * 
		 * @Title: queryPartCode
		 * @Description: TODO(根据三包规则查询配件)
		 * @param 设定文件
		 * @return void 返回类型
		 * @throws
		 */
		public void queryPartCodeFromRuleListByVinAndPartCode() {
			ActionContext act = ActionContext.getContext();
			AclUserBean logonUser = (AclUserBean) act.getSession().get(
					Constant.LOGON_USER);
			Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
			String dealerId = logonUser.getDealerId();
			StringBuffer con = new StringBuffer();
			Map<String, String> map = new HashMap<String, String>();
			try {
				RequestWrapper request = act.getRequest();
				String roNo = request.getParamValue("roNo");
				String vin = request.getParamValue("vin");
				String groupId = request.getParamValue("GROUP_ID"); // 车型
				String partCode = request.getParamValue("partCode");
				String partName = request.getParamValue("PART_NAME"); // 主页面中的主工时代码
				String supplierName = request.getParamValue("SUPPLIER_NAME");
				map.put("roNo", roNo);
				map.put("vin", vin);
				map.put("partCode", partCode);
				map.put("partName", partName);
				map.put("groupId", groupId);
				map.put("companyId", companyId.toString());
				map.put("supplierName", supplierName);
				Map<String,Object> ps = dao.queryPartCodeByVin(logonUser,
						map);
				//如果RULE_LIST表里没有该配件，查询该配件通用三包规则
				if(ps==null){
					ps = dao.queryUsualRulePartCode(partCode);
				}
				act.setOutData("ps", ps);
			} catch (Exception e) {
				BizException e1 = new BizException(act, e,
						ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
				logger.error(logonUser, e1);
				act.setException(e1);
			}
		}
		/**
		 * 查询基础表配件（三包信息变更申请）
		 * add by yx 20110107
		 */
		public void queryPartCodeFromBaseForRule() {
			ActionContext act = ActionContext.getContext();
			AclUserBean logonUser = (AclUserBean) act.getSession().get(
					Constant.LOGON_USER);
			Long companyId = GetOemcompanyId.getOemCompanyId(logonUser); // 公司ID
			String dealerId = logonUser.getDealerId();
			StringBuffer con = new StringBuffer();
			Map<String, String> map = new HashMap<String, String>();
			try {
				RequestWrapper request = act.getRequest();
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				String partCode = request.getParamValue("PART_CODE");
				String partName = request.getParamValue("PART_NAME"); // 主页面中的主工时代码
				PageResult<TmPtPartBaseExtPO> ps = dao.queryPartCodeForRuleChange(
						partCode,partName, Constant.PAGE_SIZE, curPage);
				act.setOutData("ps", ps);
			} catch (Exception e) {
				BizException e1 = new BizException(act, e,
						ErrorCodeConstant.QUERY_FAILURE_CODE, "索赔单维护");
				logger.error(logonUser, e1);
				act.setException(e1);
			}
		}
		
}
